<template>
  <div class="report--warp">
    <div class="report-con" v-if="curDocRecord.model == '远程模式'">
      <div class="report--left">
        <PatInfoComp :curDocRecord="curDocRecord" :canShowInfo="canShowInfo" />
        <HospitalInfoComp :hospitalInfo="hospitalInfo" />
      </div>
      <div class="report--main">
        <div class="templates--wrap">
          <div class="formwork--title">
            <div class="left--title4">常用词库</div>
            <div class="formwork--title--l">
              <div
                :class="['formwork--btn', { active: templateType == 'public' }]"
                @click="templateType = 'public'"
              >
                公共模板
              </div>
              <div
                :class="[
                  'formwork--btn',
                  { active: templateType == 'personal' },
                ]"
                @click="templateType = 'personal'"
              >
                个人模板
              </div>
              <div
                :class="['formwork--btn', { active: templateType == 'words' }]"
                @click="templateType = 'words'"
              >
                词库模板
              </div>
            </div>
          </div>
          <div class="templates--con">
            <div class="symptom--tree--wrap2" v-show="templateType == 'public'">
              <a-tree
                :tree-data="symptomData"
                @select="onSelect"
                class="symptom--tree"
                :replace-fields="{
                  children: 'Symptoms',
                }"
              >
              </a-tree>
            </div>
            <div
              class="symptom--tree--wrap2"
              v-show="templateType == 'personal'"
            >
              <a-tree
                :tree-data="usersymptomData"
                @select="onSelect"
                class="symptom--tree"
                :replace-fields="{
                  children: 'usersymptoms',
                }"
              >
              </a-tree>
            </div>
            <div class="symptom--tree--wrap2" v-show="templateType == 'words'">
              <a-select
                allowClear
                :show-search="true"
                :value="searchValue"
                placeholder="请输入检索词条"
                class="select--search3"
                :filter-option="false"
                :not-found-content="null"
                @search="fetchSearch"
                @change="handleSearchChange"
                label-in-value
              >
                <a-select-option
                  v-for="d in searchResult"
                  :key="d.id"
                  :title="d.text"
                >
                  {{ d.text }}
                </a-select-option>
              </a-select>
              <div class="keyboard--group2">
                <div
                  v-for="item in keyboardListData"
                  :key="item.key"
                  class="keyboard--item"
                  @click="addTag(item.key)"
                >
                  {{ item.label }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="main--content">
          <h1 class="left--title3 nopadding">
            <span>超声影像所见:</span>
          </h1>
          <textarea
            placeholder="请输入超声影像所见"
            :rows="15"
            v-model="curDocRecord.seen"
            :disabled="curDocRecord.state === 4 || curDocRecord.state === 6"
            class="report--inp2"
            @focus="
              () => {
                focusWho = 'seen';
                inpIsFocus = true;
              }
            "
            @blur="inpIsFocus = false"
            @keydown.tab="onTab"
            @click="handleonClick('seen')"
            ref="seen_remote"
          />
          <h1 class="left--title3 nopadding">
            <span>超声影像诊断提示:</span>
            <a-radio-group
              v-model="normal"
              :options="[
                { label: '阴性', value: 1 },
                { label: '阳性', value: 0 },
              ]"
              :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
            />
          </h1>
          <textarea
            placeholder="请输入超声影像诊断提示"
            :rows="15"
            v-model="curDocRecord.tips"
            :disabled="curDocRecord.state === 4 || curDocRecord.state === 6"
            class="report--inp2"
            @focus="
              () => {
                focusWho = 'tips';
                inpIsFocus = true;
              }
            "
            @blur="inpIsFocus = false"
            @keydown.tab="onTab"
            @click="handleonClick('tips')"
            ref="tips_remote"
          />
        </div>
      </div>
      <div class="report--right">
        <div class="report--img--pre">
          <div class="report--img--pre--left">
            <div class="img--sub--box">
              <span class="img--sub--info" v-show="imgInfoName">{{
                imgInfoName
              }}</span>
            </div>
            <img :src="previewImg" alt="" v-show="previewImg" />
            <i class="preview--image--sub" v-show="previewImg && !isMouseIn">{{
              measureTips
            }}</i>
          </div>
          <ul class="report--img--pre--right" v-show="previewImg">
            <li
              :class="['measure--item']"
              title="全屏"
              @click="fullScreen('in')"
            >
              <svg
                t="1673513895109"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="4462"
                width="48"
                height="48"
              >
                <path
                  d="M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"
                  p-id="4463"
                  fill="#ffffff"
                ></path>
              </svg>
            </li>
            <li
              :class="[
                'measure--item',
                {
                  reported:
                    curDocRecord.state == 4 ||
                    !canMeasure ||
                    curDocRecord.state == 6,
                },
              ]"
              title="测量"
              @click="measureHandle"
            >
              <svg
                t="1673513788195"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="3221"
                width="32"
                height="32"
              >
                <path
                  d="M43.933358 473.011011l938.177933 0.061398-0.01842 285.520849-938.178956-0.060375L43.933358 473.011011zM941.305285 717.802226l0.013304-203.943902-101.975618-0.00614-0.007163 122.366955c-0.001023 11.271718-9.134405 20.392446-20.397375 20.391423-11.262969 0-20.394305-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.004093 61.182454c0 11.272741-9.133382 20.394493-20.396352 20.393469-11.262969 0-20.394305-9.123798-20.393281-20.396539l0.00307-61.182454-61.185985-0.004093-0.007163 122.367979c-0.001023 11.271718-9.133382 20.392446-20.397375 20.391423-11.263993 0-20.395328-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.133382 20.394493-20.398398 20.393469-11.260923 0-20.392258-9.123798-20.392258-20.396539l0.004093-61.182454-61.185985-0.004093-0.008187 122.366955c-0.001023 11.271718-9.133382 20.393469-20.397375 20.392446-11.263993 0-20.394305-9.122775-20.393281-20.394493l0.007163-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.132359 20.394493-20.396352 20.394493-11.262969-0.001023-20.395328-9.124821-20.394305-20.397562l0.00307-61.182454-61.184961-0.004093-0.008187 122.366955c0 11.271718-9.131335 20.392446-20.395328 20.391423-11.262969 0-20.396352-9.121751-20.395328-20.393469l0.008187-122.366955-101.975618-0.007163L84.706618 717.746968 941.305285 717.802226z"
                  p-id="3222"
                  :fill="
                    curDocRecord.state == 4 ||
                    !canMeasure ||
                    curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                ></path>
                <path
                  d="M41.376011 335.577918l940.921529 0 0 53.721529-940.921529 0 0-53.721529Z"
                  p-id="3223"
                  :fill="
                    curDocRecord.state == 4 ||
                    !canMeasure ||
                    curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                ></path>
              </svg>
            </li>
            <li
              class="measure--item"
              title="上一张"
              @click="handleGoPreview('left')"
            >
              <svg
                t="1682487699235"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1880"
                width="30"
                height="30"
              >
                <path
                  d="M885.333333 938.713333a53.58 53.58 0 0 0 53.333334-53.433333V138.72a53.333333 53.333333 0 0 0-80.886667-45.666667L239.133333 466.333333a53.333333 53.333333 0 0 0 0 91.333334l618.666667 373.28a53.16 53.16 0 0 0 27.533333 7.766666z m-0.046666-810.666666a10.98 10.98 0 0 1 5.333333 1.42 10.466667 10.466667 0 0 1 5.42 9.286666v746.526667a10.666667 10.666667 0 0 1-16.18 9.133333l-618.666667-373.28a10.666667 10.666667 0 0 1 0-18.266666l618.666667-373.28a10.386667 10.386667 0 0 1 5.406667-1.586667zM85.333333 917.333333V106.666667a21.333333 21.333333 0 0 1 42.666667 0v810.666666a21.333333 21.333333 0 0 1-42.666667 0z"
                  fill="#ffffff"
                  p-id="1881"
                ></path>
              </svg>
            </li>
            <li
              class="measure--item"
              title="下一张"
              @click="handleGoPreview('right')"
            >
              <svg
                t="1682487805233"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="2177"
                width="30"
                height="30"
              >
                <path
                  d="M138.666667 938.713333a53.58 53.58 0 0 1-53.333334-53.433333V138.72a53.333333 53.333333 0 0 1 80.886667-45.666667l618.666667 373.28a53.333333 53.333333 0 0 1 0 91.333334l-618.666667 373.28a53.16 53.16 0 0 1-27.553333 7.766666z m0.046666-810.666666a10.98 10.98 0 0 0-5.333333 1.42 10.466667 10.466667 0 0 0-5.38 9.253333v746.56a10.666667 10.666667 0 0 0 16.18 9.133333l618.666667-373.28a10.666667 10.666667 0 0 0 0-18.266666l-618.666667-373.28a10.386667 10.386667 0 0 0-5.446667-1.586667zM938.666667 917.333333V106.666667a21.333333 21.333333 0 0 0-42.666667 0v810.666666a21.333333 21.333333 0 0 0 42.666667 0z"
                  fill="#ffffff"
                  p-id="2178"
                ></path>
              </svg>
            </li>
            <li
              :class="[
                'measure--item',
                {
                  reported: curDocRecord.state == 4 || curDocRecord.state == 6,
                },
              ]"
              title="选中"
            >
              <svg
                v-show="!curImgHasChecked"
                @click="handlePreChecked('checked')"
                t="1673514171402"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="15958"
                width="52"
                height="52"
                :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
              >
                <path
                  d="M512 182.859c-181.782 0-329.143 147.365-329.143 329.143 0 181.782 147.361 329.146 329.143 329.146 181.778 0 329.139-147.365 329.139-329.146C841.139 330.224 693.778 182.859 512 182.859zM512.004 786.291c-151.486 0-274.289-122.803-274.289-274.289 0-151.483 122.803-274.286 274.289-274.286s274.289 122.803 274.289 274.286C786.293 663.488 663.49 786.291 512.004 786.291z"
                  p-id="15959"
                  :fill="
                    curDocRecord.state == 4 || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                ></path>
              </svg>
              <svg
                v-show="curImgHasChecked"
                @click="handlePreChecked('nochecked')"
                t="1673514703257"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="16173"
                width="40"
                height="40"
                :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
              >
                <path
                  d="M512 64C264.576 64 64 264.576 64 512s200.576 448 448 448 448-200.576 448-448S759.424 64 512 64z m271.529 719.529c-35.286 35.287-76.359 62.983-122.078 82.321C614.15 885.856 563.868 896 512 896c-51.868 0-102.15-10.144-149.451-30.15-45.719-19.337-86.792-47.034-122.078-82.321-35.287-35.286-62.983-76.359-82.321-122.078C138.144 614.15 128 563.868 128 512s10.144-102.15 30.15-149.451c19.337-45.719 47.034-86.792 82.321-122.078 35.286-35.287 76.359-62.983 122.078-82.321C409.85 138.144 460.132 128 512 128c51.868 0 102.15 10.144 149.451 30.15 45.719 19.337 86.792 47.034 122.078 82.321 35.287 35.286 62.983 76.359 82.321 122.078C885.856 409.85 896 460.132 896 512s-10.144 102.15-30.15 149.451c-19.338 45.718-47.034 86.792-82.321 122.078z"
                  :fill="
                    curDocRecord.state == 4 || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="16174"
                ></path>
                <path
                  d="M707.576 362.526L448.465 621.637 316.424 489.596c-12.497-12.497-32.758-12.497-45.255 0s-12.497 32.758 0 45.255l154.668 154.668c6.249 6.249 14.438 9.373 22.627 9.373s16.379-3.124 22.627-9.373L752.83 407.781c12.497-12.497 12.497-32.758 0-45.255-12.496-12.497-32.758-12.497-45.254 0z"
                  :fill="
                    curDocRecord.state == 4 || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="16175"
                ></path>
              </svg>
            </li>
            <li
              :class="[
                'measure--item',
                {
                  reported: curDocRecord.state == 4 || curDocRecord.state == 6,
                },
              ]"
              title="删除"
              :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
            >
              <a-popconfirm
                :title="deleteTips"
                ok-text="确定"
                cancel-text="取消"
                @confirm="confirmDelete"
                placement="left"
                :disabled="
                  !curChoseImg ||
                  curDocRecord.state == 4 ||
                  curDocRecord.state == 6
                "
              >
                <svg
                  t="1673513513771"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="2029"
                  width="38"
                  height="38"
                >
                  <path
                    d="M106.666667 213.333333h810.666666v42.666667H106.666667z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="2030"
                  ></path>
                  <path
                    d="M640 128v42.666667h42.666667V128c0-23.573333-19.093333-42.666667-42.538667-42.666667H383.872A42.496 42.496 0 0 0 341.333333 128v42.666667h42.666667V128h256z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="2031"
                  ></path>
                  <path
                    d="M213.333333 896V256H170.666667v639.957333C170.666667 919.552 189.653333 938.666667 213.376 938.666667h597.248C834.218667 938.666667 853.333333 919.68 853.333333 895.957333V256h-42.666666v640H213.333333z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="2032"
                  ></path>
                  <path
                    d="M320 341.333333h42.666667v384h-42.666667zM490.666667 341.333333h42.666666v384h-42.666666zM661.333333 341.333333h42.666667v384h-42.666667z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="2033"
                  ></path>
                </svg>
              </a-popconfirm>
            </li>
          </ul>
          <div class="noimg--box" v-show="!previewImg">
            <svg
              t="1640244737865"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="1313"
              width="64"
              height="64"
            >
              <path
                d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                fill="#8a8a8a"
                p-id="1314"
              ></path>
            </svg>
            <span>暂无图片</span>
          </div>
        </div>
        <div class="report--imgs--wrap">
          <div class="left--title5">
            <div class="report--imgs--wrap-w">
              {{
                curDocRecord.state != 4 && curDocRecord.state != 6
                  ? `选择图像到报告中(${selectImgs.length}/${images.length})：`
                  : "图片影像："
              }}
            </div>
            <div class="imgs--type--box">
              <div
                :class="[
                  'imgs--type--item first',
                  { active: showImgType == 'all' },
                ]"
                @click="imgTypeChange('all')"
              >
                全部
              </div>
              <div
                :class="[
                  'imgs--type--item end',
                  {
                    active: showImgType == 'video',
                    remote: curDocRecord.model == '远程模式',
                  },
                ]"
                @click="imgTypeChange('video')"
              >
                视频
              </div>
            </div>
          </div>
          <div
            class="report--checkbox--wrap"
            v-if="showImgType != 'video'"
            ref="imgsBox"
          >
            <div class="img--total" v-if="images.length > 4">
              {{ imgCurPage }}/{{ imgPages }}
            </div>
            <div
              :class="[
                'img--dir',
                { remote: curDocRecord.model == '远程模式' },
              ]"
              v-if="images.length > 4"
              @click="goNextImgPageByDir('left')"
            >
              <a-icon type="double-left" :style="{ color: '#ffffff' }" />
            </div>
            <div
              class="img--dir right"
              v-if="images.length > 4"
              @click="goNextImgPageByDir('right')"
            >
              <a-icon type="double-right" :style="{ color: '#ffffff' }" />
            </div>
            <div class="report--checkbox">
              <template v-if="images.length > 0">
                <div
                  v-for="(item,index) in images"
                  v-show="item.visable"
                  :class="[
                    'img-box',
                    {
                      warn: item.status === 'lesion',
                      err: item.status === 'err',
                      measure: item.status == 'cali' || item.type == 'measure',
                      reported:
                        curDocRecord.state == 4 || curDocRecord.state == 6,
                    },
                  ]"
                  :key="item.id || item.param_id"
                  @click="choseImg(item,index)"
                  @dblclick="handleReporteddblClick(item)"
                  @mouseenter="handleMouseenter(item)"
                  @mouseleave="handleMouseleave"
                >
                  <img
                    :src="item.url"
                    alt=""
                    :class="[{ active: curChoseImg == item.id }]"
                  />
                  <span
                    v-if="item.info"
                    :class="[
                      'tips',
                      {
                        warn: item.status === 'lesion',
                        err: item.status === 'err',
                        measure:
                          item.status == 'cali' || item.type == 'measure',
                      },
                    ]"
                    >{{ item.info }}</span
                  >
                  <div
                    class="reported--box"
                    v-show="choseImgs.includes(item.id)"
                  >
                    <a-icon type="check" />
                  </div>
                </div>
              </template>
            </div>

            <div class="noimg--box" v-if="images.length === 0">
              <svg
                t="1640244737865"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1313"
                width="64"
                height="64"
              >
                <path
                  d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                  fill="#8a8a8a"
                  p-id="1314"
                ></path>
              </svg>
              <span>暂无图片</span>
            </div>
          </div>
          <div class="report--checkbox--wrap" v-show="showImgType == 'video'">
            <div class="report--checkbox">
              <div
                class="video-box"
                v-for="item in videoS"
                :key="item.id || item.param_id"
                @click="watchVideo(item.url, item.id)"
              >
                <video
                  class="video-box-item"
                  :src="item.url"
                  controls
                  controlsList="nodownload nofullscreen"
                ></video>
              </div>
            </div>
            <div class="noimg--box" v-if="videoS.length === 0">
              <svg
                t="1640244737865"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1313"
                width="64"
                height="64"
              >
                <path
                  d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                  fill="#8a8a8a"
                  p-id="1314"
                ></path>
              </svg>
              <span>暂无视频</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="report-con" v-if="curDocRecord.model == '自主模式'">
      <div class="report--own--left">
        <div class="own--left--title">
          <div
            :class="['left--title-item', { active: ownTabIndex == 1 }]"
            @click="ownTabIndex = 1"
            v-show="canShowInfo"
          >
            基本信息
          </div>
          <div
            :class="['left--title-item', { active: ownTabIndex == 2 }]"
            @click="ownTabIndex = 2"
          >
            自动测量
          </div>
          <div
            :class="['left--title-item', { active: ownTabIndex == 3 }]"
            @click="ownTabIndex = 3"
          >
            报告模板
          </div>
        </div>
        <div class="own--left--con">
          <div class="own--info" v-show="ownTabIndex == 1">
            <a-form
              class="own-form"
              :form="form1"
              :label-col="{ span: 6 }"
              :wrapper-col="{ span: 15 }"
            >
              <a-form-item label="受试者筛选号:">
                <a-input
                  autoComplete="off"
                  v-decorator="['sNo']"
                  :disabled="true"
                />
              </a-form-item>
              <a-form-item label="检查部位:">
                <a-input
                  autoComplete="off"
                  v-decorator="['pos']"
                  :disabled="true"
                />
              </a-form-item>
              <a-form-item label="检查状态:">
                <span class="own--form--w">{{
                  stateInfo[curDocRecord.state]
                }}</span>
              </a-form-item>
            </a-form>
          </div>
          <div class="own--info feature" v-show="ownTabIndex == 2">
            <div class="own--feature--con">
              <OwnAuto
                ref="feature"
                :status="ownTabIndex == 2"
                :pos="curDocRecord.pos"
                :featureData="curDocRecord.measureInfo"
                :recordDisabled="true"
                :type="curDocRecord.magic2"
              />
            </div>
          </div>
          <div class="own--info formwork" v-show="ownTabIndex == 3">
            <div class="formwork--title">
              <div class="formwork--title--l">
                <div
                  :class="[
                    'formwork--btn',
                    { active: templateType == 'public' },
                  ]"
                  @click="templateType = 'public'"
                >
                  公共模板
                </div>
                <div
                  :class="[
                    'formwork--btn',
                    { active: templateType == 'personal' },
                  ]"
                  @click="templateType = 'personal'"
                >
                  个人模板
                </div>
                <div
                  :class="[
                    'formwork--btn',
                    { active: templateType == 'words' },
                  ]"
                  @click="templateType = 'words'"
                >
                  词库模板
                </div>
              </div>
            </div>
            <div class="templates--con2">
              <div
                class="symptom--tree--wrap2"
                v-show="templateType == 'public'"
              >
                <a-tree
                  :tree-data="symptomData"
                  @select="onSelect"
                  class="symptom--tree"
                  :replace-fields="{
                    children: 'Symptoms',
                  }"
                >
                </a-tree>
              </div>
              <div
                class="symptom--tree--wrap2"
                v-show="templateType == 'personal'"
              >
                <a-tree
                  :tree-data="usersymptomData"
                  @select="onSelect"
                  class="symptom--tree"
                  :replace-fields="{
                    children: 'usersymptoms',
                  }"
                >
                </a-tree>
              </div>
              <div
                class="symptom--tree--wrap2"
                v-show="templateType == 'words'"
              >
                <a-select
                  allowClear
                  :show-search="true"
                  :value="searchValue"
                  placeholder="请输入检索词条"
                  class="select--search4"
                  :filter-option="false"
                  :not-found-content="null"
                  @search="fetchSearch"
                  @change="handleSearchChange"
                  label-in-value
                >
                  <a-select-option
                    v-for="d in searchResult"
                    :key="d.id"
                    :title="d.text"
                  >
                    {{ d.text }}
                  </a-select-option>
                </a-select>
                <div class="keyboard--group2">
                  <div
                    v-for="item in keyboardListData"
                    :key="item.key"
                    class="keyboard--item"
                    @click="addTag(item.key)"
                  >
                    {{ item.label }}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <OwnDrawer
          title="扫查影像合格率"
          :visible="qualification"
          @on-close="qualification = false"
          :small="watchVideoKey"
          :pos="curDocRecord.pos"
          :imgSmall="measureKey"
        >
          <div class="blind--box">
            <Qualification :pos="curDocRecord.pos" ref="Qualification" :type="curDocRecord.magic2" :small="measureKey || watchVideoKey"/>
            <div class="modal--box--footer--con">
              <a-space size="large">
                <button @click="qualification = false" class="modal-btn cancal">
                  取消
                </button>
                <a-popconfirm
                    :title="assessTips"
                  ok-text="确定"
                  cancel-text="取消"
                  @confirm="assessSubmit('qualification')"
                  placement="top"
                >
                  <button class="modal-btn">提交评价</button>
                </a-popconfirm>
              </a-space>
            </div>
          </div>
        </OwnDrawer>
        <OwnDrawer
          title="标准切面识别率"
          :visible="recognition"
          @on-close="recognition = false"
          :small="watchVideoKey"
          :pos="curDocRecord.pos"
          :imgSmall="measureKey"
        >
          <div class="blind--box">
            <Recognition :pos="curDocRecord.pos" ref="Recognition" :type="curDocRecord.magic2" :small="measureKey || watchVideoKey"/>
            <div class="modal--box--footer--con">
              <a-space size="large">
                <button @click="recognition = false" class="modal-btn cancal">
                  取消
                </button>
                <a-popconfirm
                    :title="assessTips"
                    ok-text="确定"
                    cancel-text="取消"
                    @confirm="assessSubmit('recognition')"
                    placement="top"
                >
                  <button class="modal-btn">提交评价</button>
                </a-popconfirm>
              </a-space>
            </div>
          </div>
        </OwnDrawer>
        <OwnDrawer
          title="诊断一致性"
          :visible="diagnosis"
          @on-close="diagnosis = false"
          :small="watchVideoKey"
          :pos="curDocRecord.pos"
          :imgSmall="measureKey"
        >
          <div class="blind--box">
            <Diagnosis :pos="curDocRecord.pos" ref="Diagnosis" :type="curDocRecord.magic2" :small="measureKey || watchVideoKey"/>
            <div class="modal--box--footer--con">
              <a-space size="large">
                <button @click="diagnosis = false" class="modal-btn cancal">
                  取消
                </button>
                <a-popconfirm
                    :title="assessTips"
                    ok-text="确定"
                    cancel-text="取消"
                    @confirm="assessSubmit('diagnosis')"
                    placement="top"
                >
                  <button class="modal-btn">提交评价</button>
                </a-popconfirm>
              </a-space>
            </div>
          </div></OwnDrawer
        >
      </div>
      <div class="report--own--right">
        <div class="own--right--seen">
          <div class="report--img--pre2" v-show="previewImgShow">
            <div class="report--img--pre--left">
              <div class="img--sub--box">
                <span class="img--sub--info" v-show="imgInfoName">{{
                  imgInfoName
                }}</span>
              </div>
              <img :src="previewImg" alt="" v-show="previewImg" />
              <i
                class="preview--image--sub"
                v-show="previewImg && !isMouseIn"
                >{{ measureTips }}</i
              >
            </div>
            <ul class="report--img--pre--right" v-show="previewImg">
              <li :class="['measure--item']" title="缩小" @click="reduceImg">
                <svg
                  t="1690424977607"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="3129"
                  width="32"
                  height="32"
                >
                  <path
                    d="M411.741091 558.545455a34.909091 34.909091 0 0 1 34.909091 34.90909v272.104728a34.909091 34.909091 0 1 1-69.818182 0v-187.810909L106.146909 948.433455a34.792727 34.792727 0 0 1-24.669091 10.216727 34.909091 34.909091 0 0 1-24.692363-59.578182L327.493818 628.363636H139.636364a34.909091 34.909091 0 1 1 0-69.818181h272.104727z m487.330909-501.76a34.909091 34.909091 0 1 1 49.338182 49.338181L677.748364 376.832h187.857454a34.909091 34.909091 0 1 1 0 69.818182H593.454545a34.909091 34.909091 0 0 1-34.90909-34.909091V139.636364a34.909091 34.909091 0 1 1 69.818181 0v187.810909L899.072 56.785455z"
                    fill="#ffffff"
                    p-id="3130"
                  ></path>
                </svg>
              </li>
              <li
                :class="['measure--item']"
                title="全屏"
                @click="fullScreen('in')"
              >
                <svg
                  t="1673513895109"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="4462"
                  width="48"
                  height="48"
                >
                  <path
                    d="M547.4 197.4v46l200.3 0.1L546.1 444l32.4 32.6 201.9-200.7v200.9h46V197.5zM471.4 584.4l-32.6-32.6L243.6 747V547.9h-46v278.7h279v-46H275z"
                    p-id="4463"
                    fill="#ffffff"
                  ></path>
                </svg>
              </li>
              <li
                :class="[
                  'measure--item',
                  {
                    reported:
                      curDocRecord.state == 4 ||
                      !canMeasure ||
                      curDocRecord.state == 6,
                  },
                ]"
                title="测量"
                @click="measureHandle"
              >
                <svg
                  t="1673513788195"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="3221"
                  width="32"
                  height="32"
                >
                  <path
                    d="M43.933358 473.011011l938.177933 0.061398-0.01842 285.520849-938.178956-0.060375L43.933358 473.011011zM941.305285 717.802226l0.013304-203.943902-101.975618-0.00614-0.007163 122.366955c-0.001023 11.271718-9.134405 20.392446-20.397375 20.391423-11.262969 0-20.394305-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.004093 61.182454c0 11.272741-9.133382 20.394493-20.396352 20.393469-11.262969 0-20.394305-9.123798-20.393281-20.396539l0.00307-61.182454-61.185985-0.004093-0.007163 122.367979c-0.001023 11.271718-9.133382 20.392446-20.397375 20.391423-11.263993 0-20.395328-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.133382 20.394493-20.398398 20.393469-11.260923 0-20.392258-9.123798-20.392258-20.396539l0.004093-61.182454-61.185985-0.004093-0.008187 122.366955c-0.001023 11.271718-9.133382 20.393469-20.397375 20.392446-11.263993 0-20.394305-9.122775-20.393281-20.394493l0.007163-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.132359 20.394493-20.396352 20.394493-11.262969-0.001023-20.395328-9.124821-20.394305-20.397562l0.00307-61.182454-61.184961-0.004093-0.008187 122.366955c0 11.271718-9.131335 20.392446-20.395328 20.391423-11.262969 0-20.396352-9.121751-20.395328-20.393469l0.008187-122.366955-101.975618-0.007163L84.706618 717.746968 941.305285 717.802226z"
                    p-id="3222"
                    :fill="
                      curDocRecord.state == 4 ||
                      !canMeasure ||
                      curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                  ></path>
                  <path
                    d="M41.376011 335.577918l940.921529 0 0 53.721529-940.921529 0 0-53.721529Z"
                    p-id="3223"
                    :fill="
                      curDocRecord.state == 4 ||
                      !canMeasure ||
                      curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                  ></path>
                </svg>
              </li>
              <li
                class="measure--item"
                title="上一张"
                @click="handleGoPreview('left')"
              >
                <svg
                  t="1682487699235"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="1880"
                  width="30"
                  height="30"
                >
                  <path
                    d="M885.333333 938.713333a53.58 53.58 0 0 0 53.333334-53.433333V138.72a53.333333 53.333333 0 0 0-80.886667-45.666667L239.133333 466.333333a53.333333 53.333333 0 0 0 0 91.333334l618.666667 373.28a53.16 53.16 0 0 0 27.533333 7.766666z m-0.046666-810.666666a10.98 10.98 0 0 1 5.333333 1.42 10.466667 10.466667 0 0 1 5.42 9.286666v746.526667a10.666667 10.666667 0 0 1-16.18 9.133333l-618.666667-373.28a10.666667 10.666667 0 0 1 0-18.266666l618.666667-373.28a10.386667 10.386667 0 0 1 5.406667-1.586667zM85.333333 917.333333V106.666667a21.333333 21.333333 0 0 1 42.666667 0v810.666666a21.333333 21.333333 0 0 1-42.666667 0z"
                    fill="#ffffff"
                    p-id="1881"
                  ></path>
                </svg>
              </li>
              <li
                class="measure--item"
                title="下一张"
                @click="handleGoPreview('right')"
              >
                <svg
                  t="1682487805233"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="2177"
                  width="30"
                  height="30"
                >
                  <path
                    d="M138.666667 938.713333a53.58 53.58 0 0 1-53.333334-53.433333V138.72a53.333333 53.333333 0 0 1 80.886667-45.666667l618.666667 373.28a53.333333 53.333333 0 0 1 0 91.333334l-618.666667 373.28a53.16 53.16 0 0 1-27.553333 7.766666z m0.046666-810.666666a10.98 10.98 0 0 0-5.333333 1.42 10.466667 10.466667 0 0 0-5.38 9.253333v746.56a10.666667 10.666667 0 0 0 16.18 9.133333l618.666667-373.28a10.666667 10.666667 0 0 0 0-18.266666l-618.666667-373.28a10.386667 10.386667 0 0 0-5.446667-1.586667zM938.666667 917.333333V106.666667a21.333333 21.333333 0 0 0-42.666667 0v810.666666a21.333333 21.333333 0 0 0 42.666667 0z"
                    fill="#ffffff"
                    p-id="2178"
                  ></path>
                </svg>
              </li>
              <li
                :class="[
                  'measure--item',
                  {
                    reported:
                      curDocRecord.state == 4 || curDocRecord.state == 6,
                  },
                ]"
                title="选中"
              >
                <svg
                  v-show="!curImgHasChecked"
                  @click="handlePreChecked('checked')"
                  t="1673514171402"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="15958"
                  width="52"
                  height="52"
                  :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
                >
                  <path
                    d="M512 182.859c-181.782 0-329.143 147.365-329.143 329.143 0 181.782 147.361 329.146 329.143 329.146 181.778 0 329.139-147.365 329.139-329.146C841.139 330.224 693.778 182.859 512 182.859zM512.004 786.291c-151.486 0-274.289-122.803-274.289-274.289 0-151.483 122.803-274.286 274.289-274.286s274.289 122.803 274.289 274.286C786.293 663.488 663.49 786.291 512.004 786.291z"
                    p-id="15959"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                  ></path>
                </svg>
                <svg
                  v-show="curImgHasChecked"
                  @click="handlePreChecked('nochecked')"
                  t="1673514703257"
                  class="icon"
                  viewBox="0 0 1024 1024"
                  version="1.1"
                  xmlns="http://www.w3.org/2000/svg"
                  p-id="16173"
                  width="40"
                  height="40"
                  :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
                >
                  <path
                    d="M512 64C264.576 64 64 264.576 64 512s200.576 448 448 448 448-200.576 448-448S759.424 64 512 64z m271.529 719.529c-35.286 35.287-76.359 62.983-122.078 82.321C614.15 885.856 563.868 896 512 896c-51.868 0-102.15-10.144-149.451-30.15-45.719-19.337-86.792-47.034-122.078-82.321-35.287-35.286-62.983-76.359-82.321-122.078C138.144 614.15 128 563.868 128 512s10.144-102.15 30.15-149.451c19.337-45.719 47.034-86.792 82.321-122.078 35.286-35.287 76.359-62.983 122.078-82.321C409.85 138.144 460.132 128 512 128c51.868 0 102.15 10.144 149.451 30.15 45.719 19.337 86.792 47.034 122.078 82.321 35.287 35.286 62.983 76.359 82.321 122.078C885.856 409.85 896 460.132 896 512s-10.144 102.15-30.15 149.451c-19.338 45.718-47.034 86.792-82.321 122.078z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="16174"
                  ></path>
                  <path
                    d="M707.576 362.526L448.465 621.637 316.424 489.596c-12.497-12.497-32.758-12.497-45.255 0s-12.497 32.758 0 45.255l154.668 154.668c6.249 6.249 14.438 9.373 22.627 9.373s16.379-3.124 22.627-9.373L752.83 407.781c12.497-12.497 12.497-32.758 0-45.255-12.496-12.497-32.758-12.497-45.254 0z"
                    :fill="
                      curDocRecord.state == 4 || curDocRecord.state == 6
                        ? '#707070'
                        : '#ffffff'
                    "
                    p-id="16175"
                  ></path>
                </svg>
              </li>
              <li
                :class="[
                  'measure--item',
                  {
                    reported:
                      curDocRecord.state == 4 || curDocRecord.state == 6,
                  },
                ]"
                title="删除"
                :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"
              >
                <a-popconfirm
                  :title="deleteTips"
                  ok-text="确定"
                  cancel-text="取消"
                  @confirm="confirmDelete"
                  placement="left"
                  :disabled="
                    !curChoseImg ||
                    curDocRecord.state == 4 ||
                    curDocRecord.state == 6
                  "
                >
                  <svg
                    t="1673513513771"
                    class="icon"
                    viewBox="0 0 1024 1024"
                    version="1.1"
                    xmlns="http://www.w3.org/2000/svg"
                    p-id="2029"
                    width="38"
                    height="38"
                  >
                    <path
                      d="M106.666667 213.333333h810.666666v42.666667H106.666667z"
                      :fill="
                        curDocRecord.state == 4 || curDocRecord.state == 6
                          ? '#707070'
                          : '#ffffff'
                      "
                      p-id="2030"
                    ></path>
                    <path
                      d="M640 128v42.666667h42.666667V128c0-23.573333-19.093333-42.666667-42.538667-42.666667H383.872A42.496 42.496 0 0 0 341.333333 128v42.666667h42.666667V128h256z"
                      :fill="
                        curDocRecord.state == 4 || curDocRecord.state == 6
                          ? '#707070'
                          : '#ffffff'
                      "
                      p-id="2031"
                    ></path>
                    <path
                      d="M213.333333 896V256H170.666667v639.957333C170.666667 919.552 189.653333 938.666667 213.376 938.666667h597.248C834.218667 938.666667 853.333333 919.68 853.333333 895.957333V256h-42.666666v640H213.333333z"
                      :fill="
                        curDocRecord.state == 4 || curDocRecord.state == 6
                          ? '#707070'
                          : '#ffffff'
                      "
                      p-id="2032"
                    ></path>
                    <path
                      d="M320 341.333333h42.666667v384h-42.666667zM490.666667 341.333333h42.666666v384h-42.666666zM661.333333 341.333333h42.666667v384h-42.666667z"
                      :fill="
                        curDocRecord.state == 4 || curDocRecord.state == 6
                          ? '#707070'
                          : '#ffffff'
                      "
                      p-id="2033"
                    ></path>
                  </svg>
                </a-popconfirm>
              </li>
            </ul>
            <div class="noimg--box" v-show="!previewImg">
              <svg
                t="1640244737865"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1313"
                width="64"
                height="64"
              >
                <path
                  d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                  fill="#8a8a8a"
                  p-id="1314"
                ></path>
              </svg>
              <span>暂无图片</span>
            </div>
          </div>
          <div class="own--seen--item">
            <div class="own--seen--item-w">超声影像所见:</div>
            <textarea
              class="report--inp3"
              v-model="curDocRecord.seen"
              @focus="
                () => {
                  focusWho = 'seen';
                  inpIsFocus = true;
                }
              "
              @blur="inpIsFocus = false"
              @keydown.tab="onTab"
              :disabled="recordDisabled"
              @click="handleonClick('seen')"
              ref="seen"
            ></textarea>
          </div>
          <div class="own--seen--item">
            <div class="own--seen--item-w">
              <span>超声影像诊断提示:</span>
<!--              <a-radio-group-->
<!--                v-show="!previewImgShow"-->
<!--                v-model="normal"-->
<!--                :options="[-->
<!--                  { label: '阴性', value: 1 },-->
<!--                  { label: '阳性', value: 0 },-->
<!--                ]"-->
<!--                :disabled="curDocRecord.state == 4 || curDocRecord.state == 6"-->
<!--              />-->
            </div>
            <textarea
              class="report--inp3"
              v-model="curDocRecord.tips"
              @focus="
                () => {
                  focusWho = 'tips';
                  inpIsFocus = true;
                }
              "
              @blur="inpIsFocus = false"
              @keydown.tab="onTab"
              :disabled="recordDisabled"
              @click="handleonClick('tips')"
              ref="tips"
            ></textarea>
          </div>
        </div>
        <div class="report--imgs--wrap">
          <div class="left--title5">
            <div class="report--imgs--wrap-w">
              {{
                curDocRecord.state != 4 && curDocRecord.state != 6
                  ? `选择图像到报告中(${selectImgs.length}/${images.length})：`
                  : "图片影像："
              }}
            </div>
            <div class="imgs--type--box">
              <div
                :class="[
                  'imgs--type--item',
                  { active: showImgType == 'standard' },
                ]"
                @click="imgTypeChange('standard')"
                v-if="curDocRecord.model == '自主模式'"
              >
                标准切面图
              </div>
              <!-- <div
                :class="[
                  'imgs--type--item',
                  { active: showImgType == 'tubrcle' },
                ]"
                @click="imgTypeChange('tubrcle')"
                v-if="curDocRecord.model == '自主模式'"
              >
                疑似异常图
              </div> -->
              <div
                :class="[
                  'imgs--type--item',
                  { active: showImgType == 'measure' },
                ]"
                @click="imgTypeChange('measure')"
                v-if="curDocRecord.model == '自主模式'"
              >
                测量图
              </div>
              <div
                  :class="[
                  'imgs--type--item first',
                  { active: showImgType == 'all' },
                ]"
                  @click="imgTypeChange('all')"
              >
                全部
              </div>
              <div
                :class="[
                  'imgs--type--item end',
                  {
                    active: showImgType == 'video',
                    remote: curDocRecord.model == '远程模式',
                  },
                ]"
                @click="imgTypeChange('video')"
              >
                视频
              </div>
            </div>
          </div>
          <div
            class="report--checkbox--wrap"
            v-if="showImgType != 'video'"
            ref="imgsBox"
          >
            <div class="img--total" v-if="images.length > 4">
              {{ imgCurPage }}/{{ imgPages }}
            </div>
            <div
              class="img--dir left"
              v-if="images.length > 4"
              @click="goNextImgPageByDir('left')"
            >
              <a-icon type="double-left" :style="{ color: '#ffffff' }" />
            </div>
            <div
              class="img--dir right"
              v-if="images.length > 4"
              @click="goNextImgPageByDir('right')"
            >
              <a-icon type="double-right" :style="{ color: '#ffffff' }" />
            </div>
            <div class="report--checkbox">
              <template v-if="images.length > 0">
                <div
                  v-for="(item,index) in images"
                  v-show="item.visable"
                  :class="[
                    'img-box',
                    {
                      warn: item.status === 'lesion',
                      err: item.status === 'err',
                      measure: item.status == 'cali' || item.type == 'measure',
                      reported:
                        curDocRecord.state == 4 || curDocRecord.state == 6,
                    },
                  ]"
                  :key="item.id || item.param_id"
                  @click="choseImg(item,index)"
                  @dblclick="handleReporteddblClick(item)"
                  @mouseenter="handleMouseenter(item)"
                  @mouseleave="handleMouseleave"
                >
                  <img
                    :src="item.url"
                    alt=""
                    :class="[{ active: curChoseImg == item.id }]"
                  />
                  <span
                    v-if="item.info"
                    :class="[
                      'tips',
                      {
                        warn: item.status === 'lesion',
                        err: item.status === 'err',
                        measure:
                          item.status == 'cali' || item.type == 'measure',
                      },
                    ]"
                    >{{ item.info }}</span
                  >
                  <div
                    class="reported--box"
                    v-show="choseImgs.includes(item.id)"
                  >
                    <a-icon type="check" />
                  </div>
                </div>
              </template>
            </div>
            <div class="noimg--box" v-if="images.length === 0">
              <svg
                t="1640244737865"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1313"
                width="64"
                height="64"
              >
                <path
                  d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                  fill="#8a8a8a"
                  p-id="1314"
                ></path>
              </svg>
              <span>暂无图片</span>
            </div>
          </div>
          <div class="report--checkbox--wrap" v-show="showImgType == 'video'">
            <div class="report--checkbox">
              <div
                class="video-box"
                v-for="(item, index) in videoS"
                :key="item.id + index || item.param_id + index"
                @click="watchVideo(item.url, item.id)"
              >
                <video
                  class="video-box-item"
                  :src="item.url"
                  controls
                  controlsList="nodownload nofullscreen noplaybackrate"
                  disablePictureInPicture
                ></video>
                <span class="tips" v-if="item.info">{{item.info}}</span>
              </div>
            </div>
            <div class="noimg--box" v-if="videoS.length === 0">
              <svg
                t="1640244737865"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="1313"
                width="64"
                height="64"
              >
                <path
                  d="M512 0C228.430769 0 0 228.430769 0 512s228.430769 512 512 512 512-228.430769 512-512S795.569231 0 512 0z m0 59.076923c102.4 0 196.923077 35.446154 275.692308 94.523077L153.6 787.692308c-59.076923-74.830769-94.523077-173.292308-94.523077-275.692308C59.076923 263.876923 263.876923 59.076923 512 59.076923z m0 905.846154c-102.4 0-196.923077-35.446154-275.692308-94.523077L870.4 236.307692c59.076923 74.830769 94.523077 173.292308 94.523077 275.692308 0 248.123077-204.8 452.923077-452.923077 452.923077z"
                  fill="#8a8a8a"
                  p-id="1314"
                ></path>
              </svg>
              <span>暂无视频</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="report--btn">
      <div class="report--btn--left">
        <button class="btn back3" @click="go2Record" v-preventReClick>
          返回
        </button>
        <!-- <button class="btn next" @click="beforeReport" v-preventReClick>
          上一例
        </button>
        <button class="btn next" @click="afterReport" v-preventReClick>
          下一例
        </button> -->
      </div>
      <div class="report--btn--right">
        <a-space size="large">
          <button
            :class="['btn blindReview', { dis: hasQua }]"
            v-preventReClick
            v-if="userInfo.level == 6"
            @click="handleQua"
            :disabled="hasQua"
          >
            扫查影像合格率
          </button>
          <button
            :class="['btn blindReview', { dis: hasRec }]"
            v-preventReClick
            v-if="userInfo.level == 6"
            @click="handleRec"
            :disabled="hasRec"
          >
            标准切面识别率
          </button>
          <button
            :class="['btn blindReview', { dis: hasQua }]"
            v-preventReClick
            v-if="userInfo.level == 7 && !blindReview"
            @click="handleQua"
            :disabled="hasQua"
          >
            扫查影像合格率
          </button>
          <button
            :class="['btn next2', { dis: hasDia }]"
            v-preventReClick
            v-if="userInfo.level == 7 && blindReview"
            @click="handleDia"
            :disabled="hasDia"
          >
            诊断一致性
          </button>
        </a-space>
      </div>
    </div>
    <div :class="['report--sympto--model', { active: symptomActive }]">
      <div class="report--sympto--model--head">
        {{ symptomModalInfo_title ? symptomModalInfo_title : "" }}
      </div>
      <div>
        <div class="report--sympto--model--sub">超声影像所见</div>
        <div
          class="report--sympto--model--con"
          v-html="symptomModalInfo_seen ? symptomModalInfo_seen : ''"
        ></div>
      </div>
      <div>
        <div class="report--sympto--model--sub">超声影像诊断提示</div>
        <div
          class="report--sympto--model--con2"
          v-html="symptomModalInfo_tips ? symptomModalInfo_tips : ''"
        ></div>
      </div>
      <div class="report--sympto--btn">
        <button class="btn loading" @click="loadReportSympto" v-preventReClick>
          加载
        </button>
        <button class="btn" @click="closeReportModal" v-preventReClick>
          关闭
        </button>
      </div>
    </div>
    <div
      class="report--measure"
      v-show="measureKey"
      v-disable-right-click="measureKey"
    >
      <div class="report--measure--warp">
        <div class="report--measure--left">
          <span class="report--measure--tips">{{ measureTips }}</span>
          <div class="report--measure--canvas">
            <img :src="previewImg" alt="" class="measureImg" />
            <canvas
              id="my-canvas"
              :class="['my-canvas', { active: isDraw }]"
            ></canvas>
            <ul
              class="measure--datas"
              v-show="
                curDocRecord.model == '远程模式' && measurePoints.length > 0
              "
            >
              <li class="measure--datas--sub">测距(cm)</li>
              <li
                class="measure--datas--item"
                v-for="(item, index) in measurePoints"
                :key="item.id"
              >
                <span>{{ index + 1 }}</span>
                <span class="measure--datas--item--w">距离</span>
                <span>{{ item.dis }}</span>
              </li>
            </ul>
          </div>
        </div>
        <ul class="report--measure--right">
          <li
            :class="['measure--item']"
            title="退出全屏"
            v-show="measurePoints.length > 0"
          >
            <a-popconfirm
              title="有测量数据,是否另存?"
              ok-text="确定"
              cancel-text="取消"
              @confirm="confirmSaveAndOut"
              @cancel="cancelSaveAndOut"
              placement="left"
            >
              <svg
                t="1682498950183"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="23514"
                width="50"
                height="50"
              >
                <path
                  d="M648 307.2H217.6l128-128c12.8-12.8 12.8-32 0-44.8-12.8-12.8-32-12.8-44.8 0L118.4 315.2c-6.4 6.4-9.6 14.4-9.6 22.4s3.2 16 9.6 22.4l180.8 180.8c12.8 12.8 32 12.8 44.8 0 12.8-12.8 12.8-32 0-44.8L219.2 371.2H648c120 0 216 96 216 216s-96 216-216 216H320c-17.6 0-32 14.4-32 32s14.4 32 32 32h328c155.2 0 280-124.8 280-280s-124.8-280-280-280z"
                  :fill="isDraw ? '#ffffff' : '#ffffff'"
                  p-id="23515"
                ></path>
              </svg>
            </a-popconfirm>
          </li>
          <li
            :class="['measure--item']"
            title="退出全屏"
            @click="fullScreen('out')"
            v-show="measurePoints.length == 0"
          >
            <svg
              t="1682498950183"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="23514"
              width="50"
              height="50"
            >
              <path
                d="M648 307.2H217.6l128-128c12.8-12.8 12.8-32 0-44.8-12.8-12.8-32-12.8-44.8 0L118.4 315.2c-6.4 6.4-9.6 14.4-9.6 22.4s3.2 16 9.6 22.4l180.8 180.8c12.8 12.8 32 12.8 44.8 0 12.8-12.8 12.8-32 0-44.8L219.2 371.2H648c120 0 216 96 216 216s-96 216-216 216H320c-17.6 0-32 14.4-32 32s14.4 32 32 32h328c155.2 0 280-124.8 280-280s-124.8-280-280-280z"
                :fill="isDraw ? '#ffffff' : '#ffffff'"
                p-id="23515"
              ></path>
            </svg>
          </li>
          <li
            :class="[
              'measure--item',
              {
                reported:
                  curDocRecord.state == 4 ||
                  !canMeasure ||
                  fristClick ||
                  curDocRecord.state == 6,
                active: isDraw && !fristClick,
              },
            ]"
            title="测量"
            @click="measureHandle"
          >
            <svg
              t="1673513788195"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="3221"
              width="48"
              height="48"
            >
              <path
                d="M43.933358 473.011011l938.177933 0.061398-0.01842 285.520849-938.178956-0.060375L43.933358 473.011011zM941.305285 717.802226l0.013304-203.943902-101.975618-0.00614-0.007163 122.366955c-0.001023 11.271718-9.134405 20.392446-20.397375 20.391423-11.262969 0-20.394305-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.004093 61.182454c0 11.272741-9.133382 20.394493-20.396352 20.393469-11.262969 0-20.394305-9.123798-20.393281-20.396539l0.00307-61.182454-61.185985-0.004093-0.007163 122.367979c-0.001023 11.271718-9.133382 20.392446-20.397375 20.391423-11.263993 0-20.395328-9.122775-20.394305-20.394493l0.008187-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.133382 20.394493-20.398398 20.393469-11.260923 0-20.392258-9.123798-20.392258-20.396539l0.004093-61.182454-61.185985-0.004093-0.008187 122.366955c-0.001023 11.271718-9.133382 20.393469-20.397375 20.392446-11.263993 0-20.394305-9.122775-20.393281-20.394493l0.007163-122.366955-61.185985-0.004093-0.00307 61.182454c-0.001023 11.272741-9.132359 20.394493-20.396352 20.394493-11.262969-0.001023-20.395328-9.124821-20.394305-20.397562l0.00307-61.182454-61.184961-0.004093-0.008187 122.366955c0 11.271718-9.131335 20.392446-20.395328 20.391423-11.262969 0-20.396352-9.121751-20.395328-20.393469l0.008187-122.366955-101.975618-0.007163L84.706618 717.746968 941.305285 717.802226z"
                p-id="3222"
                :fill="
                  curDocRecord.state == 4 ||
                  !canMeasure ||
                  fristClick ||
                  curDocRecord.state == 6
                    ? '#707070'
                    : '#ffffff'
                "
              ></path>
              <path
                d="M41.376011 335.577918l940.921529 0 0 53.721529-940.921529 0 0-53.721529Z"
                p-id="3223"
                :fill="
                  curDocRecord.state == 4 ||
                  !canMeasure ||
                  fristClick ||
                  curDocRecord.state == 6
                    ? '#707070'
                    : '#ffffff'
                "
              ></path>
            </svg>
          </li>
          <li
            :class="['measure--item']"
            title="上一张"
            v-show="measurePoints.length > 0"
          >
            <a-popconfirm
              title="有测量数据,是否保存?"
              ok-text="确定"
              cancel-text="取消"
              @confirm="confirmSaveAndPre('left')"
              @cancel="cancelSaveAndPre('left')"
              placement="left"
            >
              <svg
                t="1682493820152"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="2067"
                width="48"
                height="48"
              >
                <path
                  d="M885.333333 938.713333a53.58 53.58 0 0 0 53.333334-53.433333V138.72a53.333333 53.333333 0 0 0-80.886667-45.666667L239.133333 466.333333a53.333333 53.333333 0 0 0 0 91.333334l618.666667 373.28a53.16 53.16 0 0 0 27.533333 7.766666z m-0.046666-810.666666a10.98 10.98 0 0 1 5.333333 1.42 10.466667 10.466667 0 0 1 5.42 9.286666v746.526667a10.666667 10.666667 0 0 1-16.18 9.133333l-618.666667-373.28a10.666667 10.666667 0 0 1 0-18.266666l618.666667-373.28a10.386667 10.386667 0 0 1 5.406667-1.586667zM85.333333 917.333333V106.666667a21.333333 21.333333 0 0 1 42.666667 0v810.666666a21.333333 21.333333 0 0 1-42.666667 0z"
                  :fill="isDraw ? '#ffffff' : '#ffffff'"
                  p-id="2068"
                ></path>
              </svg>
            </a-popconfirm>
          </li>
          <li
            :class="['measure--item']"
            title="上一张"
            @click="handleGoPreview('left')"
            v-show="measurePoints.length == 0"
          >
            <svg
              t="1682493820152"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="2067"
              width="48"
              height="48"
            >
              <path
                d="M885.333333 938.713333a53.58 53.58 0 0 0 53.333334-53.433333V138.72a53.333333 53.333333 0 0 0-80.886667-45.666667L239.133333 466.333333a53.333333 53.333333 0 0 0 0 91.333334l618.666667 373.28a53.16 53.16 0 0 0 27.533333 7.766666z m-0.046666-810.666666a10.98 10.98 0 0 1 5.333333 1.42 10.466667 10.466667 0 0 1 5.42 9.286666v746.526667a10.666667 10.666667 0 0 1-16.18 9.133333l-618.666667-373.28a10.666667 10.666667 0 0 1 0-18.266666l618.666667-373.28a10.386667 10.386667 0 0 1 5.406667-1.586667zM85.333333 917.333333V106.666667a21.333333 21.333333 0 0 1 42.666667 0v810.666666a21.333333 21.333333 0 0 1-42.666667 0z"
                :fill="isDraw ? '#ffffff' : '#ffffff'"
                p-id="2068"
              ></path>
            </svg>
          </li>
          <li
            :class="['measure--item']"
            title="下一张"
            v-show="measurePoints.length > 0"
          >
            <a-popconfirm
              title="有测量数据,是否保存?"
              ok-text="确定"
              cancel-text="取消"
              @confirm="confirmSaveAndPre('right')"
              @cancel="cancelSaveAndPre('right')"
              placement="left"
            >
              <svg
                t="1682487805233"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="2177"
                width="48"
                height="48"
              >
                <path
                  d="M138.666667 938.713333a53.58 53.58 0 0 1-53.333334-53.433333V138.72a53.333333 53.333333 0 0 1 80.886667-45.666667l618.666667 373.28a53.333333 53.333333 0 0 1 0 91.333334l-618.666667 373.28a53.16 53.16 0 0 1-27.553333 7.766666z m0.046666-810.666666a10.98 10.98 0 0 0-5.333333 1.42 10.466667 10.466667 0 0 0-5.38 9.253333v746.56a10.666667 10.666667 0 0 0 16.18 9.133333l618.666667-373.28a10.666667 10.666667 0 0 0 0-18.266666l-618.666667-373.28a10.386667 10.386667 0 0 0-5.446667-1.586667zM938.666667 917.333333V106.666667a21.333333 21.333333 0 0 0-42.666667 0v810.666666a21.333333 21.333333 0 0 0 42.666667 0z"
                  :fill="isDraw ? '#ffffff' : '#ffffff'"
                  p-id="2178"
                ></path>
              </svg>
            </a-popconfirm>
          </li>
          <li
            :class="['measure--item']"
            title="下一张"
            @click="handleGoPreview('right')"
            v-show="measurePoints.length == 0"
          >
            <svg
              t="1682487805233"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="2177"
              width="48"
              height="48"
            >
              <path
                d="M138.666667 938.713333a53.58 53.58 0 0 1-53.333334-53.433333V138.72a53.333333 53.333333 0 0 1 80.886667-45.666667l618.666667 373.28a53.333333 53.333333 0 0 1 0 91.333334l-618.666667 373.28a53.16 53.16 0 0 1-27.553333 7.766666z m0.046666-810.666666a10.98 10.98 0 0 0-5.333333 1.42 10.466667 10.466667 0 0 0-5.38 9.253333v746.56a10.666667 10.666667 0 0 0 16.18 9.133333l618.666667-373.28a10.666667 10.666667 0 0 0 0-18.266666l-618.666667-373.28a10.386667 10.386667 0 0 0-5.446667-1.586667zM938.666667 917.333333V106.666667a21.333333 21.333333 0 0 0-42.666667 0v810.666666a21.333333 21.333333 0 0 0 42.666667 0z"
                :fill="isDraw ? '#ffffff' : '#ffffff'"
                p-id="2178"
              ></path>
            </svg>
          </li>
          <li
            :class="[
              'measure--item',
              {
                reported:
                  curDocRecord.state == 4 ||
                  measurePoints.length == 0 ||
                  curDocRecord.state == 6,
              },
            ]"
            title="另存"
            @click="confirmSave"
          >
            <svg
              t="1675060642811"
              class="icon"
              viewBox="0 0 1024 1024"
              version="1.1"
              xmlns="http://www.w3.org/2000/svg"
              p-id="6313"
              width="48"
              height="48"
            >
              <path
                d="M845.312 0.512H32.512v1022.976h958.976v-876.8L845.312 0.512z m-172.864 62.976v256H351.488v-256h320.96zM287.488 960.512V605.76l29.184-29.248h390.656l29.184 29.248v354.752H287.488z m640 0h-126.976V585.152L727.424 512H296.576L223.488 585.152v375.36H96.512V63.488h190.976v320.448h449.024V63.488h79.68l111.296 112.32v784.704z m-384-832h65.984v128H543.488v-128z"
                :fill="
                  curDocRecord.state == 4 ||
                  measurePoints.length == 0 ||
                  curDocRecord.state == 6
                    ? '#707070'
                    : '#ffffff'
                "
                p-id="6314"
              ></path>
            </svg>
          </li>
          <li
            :class="[
              'measure--item',
              {
                reported:
                  curDocRecord.state == 4 || isDraw || curDocRecord.state == 6,
              },
            ]"
            title="删除"
            :disabled="
              curDocRecord.state == 4 || isDraw || curDocRecord.state == 6
            "
          >
            <a-popconfirm
              :title="deleteTips"
              ok-text="确定"
              cancel-text="取消"
              @confirm="confirmDelete"
              placement="left"
              :disabled="
                !curChoseImg ||
                curDocRecord.state == 4 ||
                isDraw ||
                curDocRecord.state == 6
              "
            >
              <svg
                t="1673513513771"
                class="icon"
                viewBox="0 0 1024 1024"
                version="1.1"
                xmlns="http://www.w3.org/2000/svg"
                p-id="2029"
                width="48"
                height="48"
              >
                <path
                  d="M106.666667 213.333333h810.666666v42.666667H106.666667z"
                  :fill="
                    curDocRecord.state == 4 || isDraw || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="2030"
                ></path>
                <path
                  d="M640 128v42.666667h42.666667V128c0-23.573333-19.093333-42.666667-42.538667-42.666667H383.872A42.496 42.496 0 0 0 341.333333 128v42.666667h42.666667V128h256z"
                  :fill="
                    curDocRecord.state == 4 || isDraw || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="2031"
                ></path>
                <path
                  d="M213.333333 896V256H170.666667v639.957333C170.666667 919.552 189.653333 938.666667 213.376 938.666667h597.248C834.218667 938.666667 853.333333 919.68 853.333333 895.957333V256h-42.666666v640H213.333333z"
                  :fill="
                    curDocRecord.state == 4 || isDraw || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="2032"
                ></path>
                <path
                  d="M320 341.333333h42.666667v384h-42.666667zM490.666667 341.333333h42.666666v384h-42.666666zM661.333333 341.333333h42.666667v384h-42.666667z"
                  :fill="
                    curDocRecord.state == 4 || isDraw || curDocRecord.state == 6
                      ? '#707070'
                      : '#ffffff'
                  "
                  p-id="2033"
                ></path>
              </svg>
            </a-popconfirm>
          </li>
        </ul>
      </div>
    </div>
    <div class="report--video" v-show="watchVideoKey">
      <div class="report--video--wrap">
        <VideoComp
          :status="watchVideoKey"
          :videoSrc="curVideo"
          :videoId="curVideoId"
          :curDocRecord="curDocRecord"
          @on-chosevideo="chosevideo"
          @on-videoByDir="videoByDir"
          ref="videocomp"
          :videoS="videoS"
        />
      </div>
    </div>
    <ModalSlot
      :visible="reportSymptomModalKey"
      title="加载报告模板提醒"
      @handleCancel="reportSymptomModalKey = false"
      @handleOk="reportSymptomModalKey = false"
      :width="330"
      name="report--tips"
    >
      <div class="report--tips--warp">
        <div class="report--tips--warp--title">
          <svg
            t="1669619439899"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="2671"
            width="16"
            height="16"
          >
            <path
              d="M512 14.208c274.56 0 497.792 223.168 497.792 497.792 0 274.56-223.168 497.792-497.792 497.792C237.44 1009.792 14.208 786.56 14.208 512 14.208 237.44 237.44 14.208 512 14.208z m0 71.104A427.072 427.072 0 0 0 85.312 512 427.072 427.072 0 0 0 512 938.688 427.072 427.072 0 0 0 938.688 512 427.072 427.072 0 0 0 512 85.312z m35.584 628.16v71.104H476.416v-71.04h71.168z m0-474.048v402.944H476.416V239.424h71.168z"
              p-id="2672"
              fill="#d81e06"
            ></path>
          </svg>
          <span class="report--tips--warp--sub">是否覆盖当前模板内容</span>
        </div>
        <div class="report--tips--warp--btn--box">
          <button
            class="report--tips--warp--btn left"
            @click="noCover"
            v-preventReClick
          >
            不覆盖
          </button>
          <button
            class="report--tips--warp--btn"
            @click="Cover"
            v-preventReClick
          >
            覆盖
          </button>
        </div>
      </div>
    </ModalSlot>
    <Intelligent
      :pos="curDocRecord && curDocRecord.pos"
      :visible="false"
      :large="measureKey"
      :recordDisabled="recordDisabled"
      ref="intelligent"
    />
  </div>
</template>

<script>
// import { createReportDom3 } from "@/utils/createReportDom2";
// import { printHtml2 } from "@/utils/print";
// import JSPDF from "jspdf";
// import Report from "@/components/customReport";
import ModalSlot from "@/components/ModalSlot";
import moment from "moment";
import html2canvas from "html2canvas";
import { mapState } from "vuex";
import { getSymptom, getSymptomByTitle } from "@/api/symptom";
import { getAllSymptomSub, bulkCreateSymptomSubAndSym } from "@/api/SymptomSub";
import dellSymptopmJson from "@/utils/dellSymptomJson";
import {
  unique,
  sortByArr,
  deleteArrById3,
  deleteArrById2,
  px2cm,
  distance,
  convertBase64UrlToBlob3,
  stateInfo,
  genderOpts,
  getIpAndPortMore,
  getSymptomTitleByPos,
  // get2RandomIdByImgList,
  // findChoseImg,
  // combineAndUnique,
  // looseEqual,
  findNextVisibleIndex,
  arteryCaliShow
} from "@/utils";
import { v4 as uuidv4 } from "uuid";
import { getAllSearchSymbol, getSearchByCode } from "../api/searchInfo";
import VideoComp from "@/components/PaVideoComp";
import OwnAuto from "@/components/OwnAuto";
import PatInfoComp from "@/components/PatInfoComp";
import HospitalInfoComp from "@/components/HospitalInfoComp";
import { getAllUserSymptomSub } from "@/api/usersymptomSub";
// import { addUserSymptom } from "@/api/userSymptom";
import {
  dellImgInfo,
  dellReportImgInfo,
  delLesionInfo,
  MergeArrays,
  dellVideoInfo,
  customSortAndLabel
} from "@/utils/dellImg";
import {
  updateRecord,
  getRecordById,
  findRecordAndPatient,
  // print2Device,
} from "@/api/recordInfo";
import { getImgParamById } from "@/api/imgParamInfo";
import { uploadMeasureImage, addMeasureImage } from "@/api/FCSCenter";
import { dellReportInfo, dellHospitalInfo } from "@/utils/dellReportData";
import { addLogInfo } from "@/api/logInfo";
import Intelligent from "@/components/Intelligent";
import Qualification from "@/components/Qualification";
import Recognition from "@/components/Recognition";
import Diagnosis from "@/components/Diagnosis";
import { getAssessById, updateAssess } from "@/api/assess";
import OwnDrawer from "@/components/OwnDrawer";
export default {
  name: "report5",
  props: {
    linkStatus: {
      type: Boolean,
    },
    visible: {
      type: Boolean,
    },
  },
  data() {
    return {
      curDocRecord: "", //当前检查信息
      stateInfo: stateInfo,
      seen: "",
      tips: "",
      images: [],
      reportModal: false,
      isSendReport: false,
      symptomData: [],
      previewImg: "",
      selectImgs: [], //选择的图片
      choseImgs: [],
      selectImgsById: [],
      exportModalVisible: false,
      exportAddress: { value: "local", label: "本地" },
      isReporting: false, //是否正在导出
      symptomActive: false,
      symptomModalInfo_title: "",
      symptomModalInfo_seen: "",
      symptomModalInfo_tips: "",
      reportSymptomModalKey: false,
      keyboardListData: [],
      options: genderOpts,
      searchResult: [],
      searchValue: undefined,
      tableData: "",
      currentPage: "",
      page: "",
      limit: "",
      imgInfoName: "", //选中的图片名
      curChoseImg: "", //当前选中图片的id
      curImgIndex: "", //当前预览图片的索引
      curImgHasChecked: false, //当前预览的图片是否选中
      measureKey: false, //测量图层key
      watchVideoKey: false, //查看视频key
      canvas: null, //
      ctx: null,
      width: "",
      height: "",
      isDraw: false, //是否在测量
      startX: 0,
      startY: 0,
      endX: 0,
      endY: 0,
      fristClick: false, //左键第一次点击
      secondClick: false,
      real_dis: 0, //真实的测量距离
      imgData: null, //暂存的canvas数据
      temporaryImgData: null, //临时的canvas数据
      canMeasure: true,
      measurePoints: [], //点集合
      chosePointIndex: null, //选中点的索引
      curImgParams: null, //当前图片的参数
      initRecordData: "",
      videoS: "", //视频数组
      curVideo: "", //当前视频地址
      curVideoId: "",
      isMouseIn: false, //鼠标是否进入
      templateType: "public", //public公共  personal个人 words词库
      showImgType: "all", //all 全部 standard 标准切面 measure测量 tubrcle病灶 video 视频
      ownTabIndex: 1, //自主模式下的 1基本信息 2特征分析 3报告模板
      form1: this.$form.createForm(this, { name: "owninfo" }),
      birth: "",
      year: "",
      focusWho: "",
      origin_symptomModalInfo_seen: "", //暂存模板字符串
      origin_symptomModalInfo_tips: "", //暂存模板字符串
      isDbClick: false, //是否双击
      selfsymptomKey: false, //个人模板
      previewImgShow: false, //图片预览显示key
      saveMeasureKey: false, //保存测量节流
      posSelectOpts: [
        { value: "颈动脉", label: "颈动脉" },
        { value: "甲状腺", label: "甲状腺" },
        { value: "泌尿", label: "泌尿" },
        { value: "腹部", label: "腹部" },
      ],
      posInpVal: "",
      record_id: "",
      patient_sn: "",
      usersymptomData: [], //个人模板数据
      userSymTitle: "", //个人模板名称
      userSymObj: null,
      selectionStart_seen: 0, //光标的位置
      selectionStart_tips: 0, //光标的位置
      oriReportimg: "", //原始的reportimg
      changedImgInfos: [],
      inpIsFocus: false,
      imgPages: 0, //图片区域总页数
      imgCurPage: 1, //当前页数
      normal: 1,
      LesionInfo: [],
      qualification: false,
      recognition: false,
      diagnosis: false,
      forms: [],
      hasQua: false, //是否提交过
      hasRec: false, //是否提交过
      hasDia: false, //是否提交过
      showImgArr:[]
    };
  },

  components: {
    ModalSlot,
    OwnDrawer,
    VideoComp,
    PatInfoComp,
    HospitalInfoComp,
    OwnAuto,
    Intelligent,
    Qualification,
    Recognition,
    Diagnosis,
  },
  computed: {
    ...mapState([
      "LOCAL_URL",
      "SERVERBASE_URL",
      "userInfo",
      "RECORD_URL",
      "MANAGA_URL",
      "userInfo",
      "blindReview",
    ]),
    //用来预览
    reportInfo() {
      const hospital = this.curDocRecord.patient_user_info
        ? JSON.parse(this.curDocRecord.patient_user_info).hospital
        : this.curDocRecord.doctor_user_info
        ? JSON.parse(this.curDocRecord.doctor_user_info).hospital
        : "";
      return dellReportInfo(
        this.curDocRecord,
        this.selectImgs,
        this.userInfo,
        hospital,
        this.userInfo,
        hospital
      );
    },
    //医院信息
    hospitalInfo() {
      const hospital = this.curDocRecord.patient_user_info
        ? JSON.parse(this.curDocRecord.patient_user_info).hospital
        : this.curDocRecord.doctor_user_info
        ? JSON.parse(this.curDocRecord.doctor_user_info).hospital
        : "";
      return dellHospitalInfo(
        this.curDocRecord,
        this.userInfo,
        hospital,
        this.userInfo,
        hospital
      );
    },
    //删除提示文字
    deleteTips() {
      if (this.curChoseImg) {
        return "确定删除么?";
      } else {
        return "请选图片！";
      }
    },
    measureTips() {
      if (this.images.length > 0) {
        return `${this.curImgIndex + 1}/${this.images.length}`;
      } else {
        return "";
      }
    },
    //该患者的所有检查记录中有已出报告吗
    recordDisabled() {
      if (
        (this.curDocRecord && this.curDocRecord.state === 4) ||
        (this.curDocRecord && this.curDocRecord.state === 6)
      ) {
        return true;
      } else {
        return false;
      }
    },
    canShowInfo() {
      if (this.blindReview) {
        return false;
      } else {
        return true;
      }
    },
    assessTips(){
      if(this.userInfo.level == 7 && !this.blindReview){
        return "一旦提交不可修改!"
      }else{
        return "是否确认提交!"
      }
    },
  },
  watch: {
    visible(newVal) {
      if (!newVal) {
        this.resetData();
      }
    },
    curImgIndex(newVal) {
      console.log("curImgIndex", newVal);
      if (this.images.length > 0 && typeof newVal == "number") {
        const type = this.images[newVal].type;
        if (type && type == "measure") {
          this.canMeasure = false;
        } else {
          this.canMeasure = true;
          if (
            this.curDocRecord.model == "自主模式" ||
            this.curDocRecord.model == "远程模式"
          ) {
            const curImgId = this.images[newVal].id;
            const patient_sn = this.curDocRecord.patient_sn;
            if (curImgId) {
              getImgParamById(this.RECORD_URL, curImgId, patient_sn)
                .then((res) => {
                  if (res.code == 200) {
                    const imgParas = JSON.parse(res.data.params);
                    if (imgParas && imgParas.length > 0) {
                      const params = {};
                      imgParas.forEach((item) => {
                        params[item.name] = item.value;
                      });
                      this.curImgParams = { ...params };
                      console.log("this.curImgParams", this.curImgParams);
                    } else {
                      this.curImgParams = null;
                    }
                  }
                })
                .catch((err) => {
                  console.log(err);
                });
            }
          }
        }
      }
    },
    curChoseImg(newId, oldId) {
      if (!oldId && newId) {
        const curImgInfo = this.oriReportimg.find(
          (item) => item.param_id == newId
        );
        this.$refs.intelligent.reSetDate();
        console.log("curChoseImg ：当前图片信息", curImgInfo);
        let new_measurePoints;
        if (curImgInfo) {
          const target = this.LesionInfo.find(
            (item) => `${item.lesionId}.jpg` == newId
          );
          if (target) {
            new_measurePoints = [
              { id: `1${newId}`, flag: 0, dis: target.dis1 },
              { id: `2${newId}`, flag: 0, dis: target.dis2 },
            ];
          }
          if (curImgInfo.measurePoints && new_measurePoints) {
            curImgInfo.measurePoints = MergeArrays(
              curImgInfo.measurePoints,
              new_measurePoints
            );
          } else if (!curImgInfo.measurePoints && new_measurePoints) {
            curImgInfo.measurePoints = [...new_measurePoints];
          }
          const info = { ...curImgInfo };
          delete info.record_id;
          delete info.type;
          delete info.url;
          this.$refs.intelligent.initIntelligentVal({ ...info });
        }
      } else if (oldId && newId && oldId != newId) {
        //先看是否有改动
        this.intelligentHasChange();
        this.$refs.intelligent.reSetDate();
        const curImgInfo = this.oriReportimg.find(
          (item) => item.param_id == newId
        );
        console.log("curChoseImg ：当前图片信息", curImgInfo);
        let new_measurePoints;
        if (curImgInfo) {
          const target = this.LesionInfo.find(
            (item) => `${item.lesionId}.jpg` == newId
          );
          if (target) {
            new_measurePoints = [
              { id: `1${newId}`, flag: 0, dis: target.dis1 },
              { id: `2${newId}`, flag: 0, dis: target.dis2 },
            ];
          }
          if (curImgInfo.measurePoints && new_measurePoints) {
            curImgInfo.measurePoints = MergeArrays(
              curImgInfo.measurePoints,
              new_measurePoints
            );
          } else if (!curImgInfo.measurePoints && new_measurePoints) {
            curImgInfo.measurePoints = [...new_measurePoints];
          }
          const info = { ...curImgInfo };
          delete info.record_id;
          delete info.type;
          delete info.url;
          this.$refs.intelligent.initIntelligentVal({ ...info });
        }
      } else {
        console.log("没有图片", newId, oldId);
      }
    },
    measureKey(newVal) {
      if (newVal) {
        this.$nextTick(() => {
          this.initCanvas();
        });
      } else {
        this.resetCanvasData();
        this.isDbClick = false;
      }
    },
    templateType(val) {
      if (val == "personal") {
        this.initUserSym();
        this.searchValue = undefined;
        this.searchResult = [];
      }
    },
    measurePoints(val) {
      if (this.curDocRecord.model == "自主模式") {
        this.$refs.intelligent.updateMeasurePoints(val);
      }
    },
    showImgType(val) {
      if (val) {
        const showList = this.images.filter((item) => item.visable);
        const showLen = showList.length;
        let grupNum = 4;
        if (this.curDocRecord.model == "远程模式") {
          grupNum = 3;
        }
        this.imgCurPage = 1;
        if (showLen > 4) {
          this.imgPages = Math.ceil(showLen / grupNum);
        } else {
          this.imgPages = 1;
        }
        $(".report--checkbox--wrap").animate({ scrollLeft: 0 });
        this.curImgIndex = this.showImgArr[0].oriIndex;
      }
    },
  },
  mounted() {
    //监听检查报告切换
    console.log("route.params :", this.$route.params);
    if (this.$route.params.id) {
      if (this.$route.params.patient_sn) {
        this.patient_sn = this.$route.params.patient_sn;
        window.localStorage.setItem(
          "patient_sn",
          this.$route.params.patient_sn
        );
      } else {
        this.patient_sn = window.localStorage.getItem("patient_sn");
      }
      const forms = window.localStorage.getItem("forms");
      if (forms) {
        this.forms = JSON.parse(window.localStorage.getItem("forms"));
      }
      this.record_id = this.$route.params.id;
      this.getReportData(this.record_id, "", this.patient_sn);
    }
    this.$EventBus.$on("updateReport", this.getReportData);
  },

  methods: {
    async getReportData(record, type, patient_sn) {
      try {
        const params = {
          id: record,
          patient_sn,
        };
        const recordRes = await getRecordById(this.RECORD_URL, params);
        if (recordRes.code === 200) {
          this.init(recordRes.data, type);
          const recordParams = JSON.parse(
            window.localStorage.getItem("tableData")
          );
          this.tableData = recordParams.tableData;
          this.currentPage = recordParams.currentPage;
          this.total = recordParams.total;
          this.limit = recordParams.limit;
        } else {
          console.log("recordRes", recordRes.msg);
        }
        if (type) {
          console.log("getReportData1");
        } else {
          console.log("getReportData2");
        }
      } catch (err) {
        console.log(err);
      }
    },
    init(data, type) {
      try {
        const vm = this;
        this.isDbClick = false;
        this.isSendReport = false;
        this.images = data.reportimg ? JSON.parse(data.reportimg) : [];
        this.videoS = data.videos ? JSON.parse(data.videos) : [];
        this.normal = data?.normal;
        if (this.videoS.length > 0) {
          this.videoS = this.videoS.map((item) => {
            return {
              pid: item.record_id,
              id: item.param_id,
              type: item.type,
              url: item.url,
              info:dellVideoInfo(item.url,data.pos,data.magic2)
            };
          });
        }
        if (this.images.length > 0) {
          this.images = this.images.map((item) => {
            return {
              pid: item.record_id,
              id: item.param_id,
              type: item.type,
              url: item.url,
              isChoosed: item.isChoosed,
              imgIndex: item.imgIndex,
            };
          });
          this.images = unique(this.images);
          //根据定义设置图片信息
          dellImgInfo(this.images, data.pos, data.model);
          this.oriReportimg = dellReportImgInfo(
            data.reportimg,
            data.pos,
            data.model,
            data.measureInfo
          );
          const measureInfo = data.measureInfo
            ? JSON.parse(data.measureInfo)
            : {};
          this.LesionInfo = measureInfo.LesionInfo
            ? measureInfo.LesionInfo
            : [];
          console.log("每一张图片的智能结构化信息", this.oriReportimg);
        }
        if (type) {
          const seen = this.curDocRecord.seen;
          const tips = this.curDocRecord.tips;
          this.curDocRecord = { ...data, seen, tips };
        } else {
          this.curDocRecord = { ...data };
        }
        this.$set(
          this.curDocRecord,
          "measureInfo",
          data.measureInfo ? data.measureInfo : JSON.stringify({})
        );
        this.initRecordData = { ...data };

        //选择的图片id集合
        this.selectImgsById = this.curDocRecord.choseImg
          ? JSON.parse(this.curDocRecord.choseImg)
          : [];
        this.choseImgs = this.curDocRecord.choseImg
          ? JSON.parse(this.curDocRecord.choseImg)
          : [];
        //选择的图片集合
        this.selectImgs = this.images.filter((item) => {
          return this.choseImgs.includes(item.id);
        });
        //选择的图片根据choseImgs排序
        if (this.selectImgs.length > 0 && this.choseImgs.length > 0) {
          this.selectImgs = sortByArr(this.selectImgs, this.choseImgs);
        }
        if (this.curDocRecord.model == "远程模式") {
          //当前选择的图片
          if (this.selectImgs.length > 0) {
            const selectImgs = [...this.selectImgs];
            const len = selectImgs.length;
            const last_selectImg = selectImgs[len - 1];
            this.imgInfoName = last_selectImg.info;
            this.curChoseImg = last_selectImg.id;
            this.previewImg = last_selectImg.image || last_selectImg.url;
          } else {
            this.imgInfoName = "";
            this.curChoseImg = "";
            this.previewImg = "";
          }
          //当前的图片是否被选中
          if (this.curChoseImg && this.choseImgs.length > 0) {
            this.curImgHasChecked = this.choseImgs.includes(this.curChoseImg);
          }
          //已经暂存过选择的图片的索引
          if (this.curChoseImg && this.images.length > 0) {
            this.images.forEach((item, index) => {
              if (item.id == this.curChoseImg) {
                this.curImgIndex = index;
              }
            });
          } else {
            this.curImgIndex = 0;
          }
          console.log("已经暂存过选择的图片的索引", this.curImgIndex);
        }
        if (this.measureKey && !this.curImgIndex) {
          this.measureKey = false;
        }
        //获取报告模板
        if (!type) {
          vm.initSym();
          vm.initSymbol();
        } else {
          this.setIntelligentOriVal(this.curChoseImg);
        }
        if (this.curDocRecord.model == "自主模式") {
          this.images = customSortAndLabel(this.images,data.pos,data.magic2)
          this.initPatientInfo();
        } else if (this.curDocRecord.model == "远程模式") {
          this.showImgType = "all";
        }
        // this.initImgPages();
      } catch (err) {
        console.log(err);
      }
    },
    //自主模式时初始化患者信息回填
    initPatientInfo() {
      this.ownTabIndex = 2;
      this.imgTypeChange("standard")
      const obj = {
        sNo: this.curDocRecord.sNo,
        pos: this.curDocRecord.pos,
      };
      const info = {
        liver: "肝胆胰",
        spleen: "脾脏",
      };
      if(this.curDocRecord.magic2){
        obj.pos = info[this.curDocRecord.magic2]
      }
      this.$nextTick(() => {
        this.form1.setFieldsValue(obj);
      });
    },
    //初始化模板
    async initSym() {
      const allSym = await getAllSymptomSub(this.SERVERBASE_URL);
      const vm = this;
      if (allSym.data && allSym.data.length == 0) {
        const res = await getSymptom(this.SERVERBASE_URL);
        const { SymSubs, SymS } = dellSymptopmJson(res.data);
        const result = await bulkCreateSymptomSubAndSym(this.SERVERBASE_URL, {
          SymSubs,
          SymS,
        });
        console.log("初始化模板", result);
      } else {
        allSym.data.forEach((item) => {
          if (item.Symptoms.length > 0) {
            item.Symptoms = item.Symptoms.sort(
              (obj1, obj2) => obj1.snumber - obj2.snumber
            );
          }
        });
        allSym.data.sort((obj1, obj2) => obj1.snumber - obj2.snumber);
        vm.symptomData = allSym.data;
        //如果暂存过则需要找出对应模板
        if (this.curDocRecord.model == "自主模式" && this.curDocRecord.seen) {
          this.findOriginSeen(allSym.data);
        }
      }
    },
    async initUserSym() {
      try {
        const allSym = await getAllUserSymptomSub(
          this.SERVERBASE_URL,
          this.$store.state.userInfo.id
        );
        if (allSym.data && allSym.data.length == 0) {
          this.$message.warning("请导入个人模板");
        }
        allSym.data.forEach((item) => {
          if (item.usersymptoms.length > 0) {
            item.usersymptoms = item.usersymptoms.sort(
              (obj1, obj2) => obj1.snumber - obj2.snumber
            );
          }
        });
        allSym.data.sort((obj1, obj2) => obj1.snumber - obj2.snumber);
        this.usersymptomData = allSym.data;
      } catch (error) {
        console.log("initUserSym", error);
      }
    },
    //初始化常用符号
    async initSymbol() {
      const res = await getAllSearchSymbol(this.SERVERBASE_URL);
      if (res.code === 200) {
        if (res.data && res.data.length !== 0) {
          this.keyboardListData = [];
          res.data.forEach((item) => {
            this.keyboardListData.push({
              key: item.detail,
              label: item.detail,
            });
          });
        } else {
          this.$message.error(`请导入常用词库!`);
          this.keyboardListData = [];
        }
      }
    },
    async fetchSearch(value) {
      if (value) {
        const res = await getSearchByCode(this.SERVERBASE_URL, value);
        console.log("------常用符号---", res);
        if (res.code === 200) {
          if (res.data && res.data.length !== 0) {
            this.searchResult = [];
            res.data.forEach((item) => {
              this.searchResult.push({
                value: item.detail,
                text: item.detail,
                id: item.id,
              });
            });
          } else {
            this.searchResult = [];
          }
        }
      } else {
        this.searchResult = [];
      }
    },
    handleSearchChange(value) {
      console.log("handleSearchChange:", value);
      if (value.label) {
        this.searchValue = value.label;
        this.addTag(value.label);
      }
    },
    //性别改变
    sexChange(e) {
      this.$set(this.curDocRecord, "sex", e.target.value);
    },
    //日期改变处理函数
    dateChange(date, dateString) {
      this.birth = dateString;
      if (date) {
        let newYear = moment().diff(moment(dateString), "years");
        let months = moment().diff(moment(dateString), "months");
        let year;
        if (months == 0 && newYear == 0) {
          year = 1;
        } else if (months > 0 && months < 12) {
          year = months;
        } else if (months >= 12) {
          year = newYear;
        }
        this.form1.setFieldsValue({ year: year });
        this.year = year;
      }
    },
    //年龄改变
    yearChange(val) {
      if (val === "" || val === null || !$.isNumeric(val)) {
        this.$message.warning(`请输入正确的年龄!`);
        this.$nextTick(() => {
          this.form1.setFieldsValue({ year: 0 });
        });
        return;
      }
      const now_year =
        val === 0
          ? new Date().getFullYear() - val
          : new Date().getFullYear() - val;
      let now_month = new Date().getMonth() + 1;
      let now_day = new Date().getDate();
      if (now_month < 10) {
        now_month = `0${now_month}`;
      }
      if (now_day < 10) {
        now_day = `0${now_day}`;
      }
      const nowT = `${now_year}${now_month}${now_day}`;
      this.birth = `${now_year}-${now_month}-${now_day}`;
      this.form1.setFieldsValue({ birth: moment(nowT) });
      this.year = val;
    },
    posHandleChange(value) {
      const vm = this;
      vm.form1.setFieldsValue({ pos: value });
      this.$set(this.curDocRecord, "pos", value);
      this.posInpVal = "";
    },
    posHandleBlur() {
      console.log("posHandleBlur", this.posInpVal);
      if (this.posInpVal) {
        if (!this.posSelectOpts.some((item) => item.value === this.posInpVal)) {
          this.posSelectOpts.push({
            value: this.posInpVal,
            label: this.posInpVal,
          });
          this.$set(this.curDocRecord, "pos", this.posInpVal);
          this.form1.setFieldsValue({ pos: this.posInpVal });
        }
      }
    },
    filterOption(input) {
      this.posInpVal = input;
    },
    //鼠标移入图片处理
    handleMouseenter(data) {
      try {
        this.isMouseIn = true;
        this.imgInfoName = data.info;
        this.previewImg = data.image || data.url;
        this.previewImgShow = true;
      } catch (err) {
        console.log(err);
      }
    },
    //鼠标移出图片处理
    handleMouseleave() {
      try {
        let choseImg_url;
        let choseImge_name;
        this.images.map((item) => {
          if (item.id == this.curChoseImg) {
            choseImg_url = item.url || item.image;
            choseImge_name = item.info;
          }
        });
        const isSame = choseImg_url == this.previewImg;
        console.log("单击选择的图片是否跟此时鼠标移出的图片是同一张", isSame);
        if (isSame) {
          return;
        } else {
          if (this.curChoseImg) {
            this.previewImg = choseImg_url;
            this.imgInfoName = choseImge_name;
          } else {
            this.imgInfoName = "";
            this.previewImg = "";
            this.previewImgShow = false;
          }
        }
        this.isMouseIn = false;
      } catch (err) {
        console.log(err);
      }
    },
    //根据方向处理预览图片
    handleGoPreview(dir) {
      try {
        if (!dir) return;
        // 初始的curImgIndex
        let newIndex = this.curImgIndex;
        const len = this.showImgArr.length;
        let start = this.showImgArr[0].oriIndex || 0;
        let end = this.showImgArr[len - 1].oriIndex || this.images.length - 1;
        console.log("start",start,"end",end)
        // 方向控制
        if (dir === "left") {
          // 向左浏览
          newIndex = findNextVisibleIndex(this.images, newIndex, -1); // 向左，curImgIndex减小
          if (newIndex <= start) {
            newIndex = start
            this.$message.warning("第一张图片");
          }
        } else if (dir === "right") {
          // 向右浏览
          newIndex = findNextVisibleIndex(this.images, newIndex, 1); // 向右，curImgIndex增加
          if (newIndex >= end) {
            newIndex = end
            this.$message.warning("最后一张图片");
          }
        }
        console.log("newIndex",newIndex);
        // 更新curImgIndex
        this.curImgIndex = newIndex;
        if (this.isDraw) {
          const type = this.images[this.curImgIndex].type;
          if (type && type == "measure") {
            this.canMeasure = false;
          }
          if (!this.canMeasure) {
            this.isDraw = false;
            this.canvas.removeEventListener("mousedown", this.onMouseDown);
            this.canvas.removeEventListener("mousemove", this.onMouseMove);
          }
        }
        this.imgInfoName = this.images[this.curImgIndex].info;
        this.curChoseImg = this.images[this.curImgIndex].id;
        this.previewImg = this.images[this.curImgIndex].url;
        //当前的图片是否被选中
        if (this.curChoseImg && this.choseImgs.length > 0) {
          this.curImgHasChecked = this.choseImgs.includes(this.curChoseImg);
        } else {
          this.curImgHasChecked = false;
        }
      } catch (err) {
        console.log(err);
      }
    },
    //预览图片选中取消处理
    handlePreChecked(val) {
      try {
        if (this.isDraw) return;
        if (this.curDocRecord.state == 4 || this.curDocRecord.state == 6) {
          return;
        }
        if (val == "nochecked") {
          let index = this.choseImgs.indexOf(this.curChoseImg);
          if (index !== -1) {
            this.choseImgs.splice(index, 1);
          }
        } else if (val == "checked") {
          if (!this.choseImgs.includes(this.curChoseImg)) {
            this.choseImgs.push(this.curChoseImg);
          }
        }
        //当前的图片是否被选中
        if (this.curChoseImg && this.choseImgs.length > 0) {
          this.curImgHasChecked = this.choseImgs.includes(this.curChoseImg);
        } else {
          this.curImgHasChecked = false;
        }
        this.selectImgs = this.images.filter((item) => {
          return this.choseImgs.includes(item.id);
        });
        if (this.selectImgs.length > 0 && this.choseImgs.length > 0) {
          this.selectImgs = sortByArr(this.selectImgs, this.choseImgs);
        }
      } catch (err) {
        console.log(err);
      }
    },
    //处理鼠标单击事件
    choseImg(img,img_index) {
      try {
        console.log("处理鼠标单击事件", img);
        this.isDbClick = true;
        this.previewImg = img.image || img.url;
        this.previewImgShow = true;
        this.curChoseImg = img.id;
        //选择的图片的索引
        if (this.curChoseImg && this.images.length > 0) {
          this.images.forEach((item, index) => {
            if (item.id == this.curChoseImg) {
              this.curImgIndex = index;
            }
          });
        } else {
          this.curImgIndex = 0;
        }
        if (this.curChoseImg && this.choseImgs.length > 0) {
          this.curImgHasChecked = this.choseImgs.includes(this.curChoseImg);
        } else {
          this.curImgHasChecked = false;
        }
        const showList = this.images.filter((item) => item.visable);
        const showLen = showList.length;
        let img_index_cur = showList.findIndex(item=>item.id == this.curChoseImg)
        let grupNum = 4;
        let i;
        if(img_index == img_index_cur){
          i = img_index
        }else {
          i = img_index_cur
        }
        if(i + 1 <= grupNum) {
          this.imgCurPage = 1
        } else{
          this.imgCurPage = Math.ceil((i + 1) / grupNum);
        }
        console.log("单击图片index:",img_index,"显示图片index:",img_index_cur ,"图片总长:",showLen,"当前在组:",this.imgCurPage)
      } catch (err) {
        console.log(err);
      }
    },
    //处理鼠标双击事件-选中图片
    handleReporteddblClick(val) {
      try {
        if (this.curDocRecord.state == 4 || this.curDocRecord.state == 6) {
          return;
        }
        this.isDbClick = true;
        if (this.choseImgs.includes(val.id)) {
          console.log("选择的图片中有该图片");
          let index = this.choseImgs.indexOf(val.id);
          if (index !== -1) {
            this.choseImgs.splice(index, 1);
          }
        } else {
          console.log("选择的图片中没有该图片");
          this.choseImgs.push(val.id);
        }
        this.selectImgsById = [...this.choseImgs];
        this.selectImgs = this.images.filter((item) => {
          return this.choseImgs.includes(item.id);
        });
        if (this.selectImgs.length > 0 && this.choseImgs.length > 0) {
          this.selectImgs = sortByArr(this.selectImgs, this.choseImgs);
        }
        //当前的图片是否被选中
        if (this.curChoseImg && this.choseImgs.length > 0) {
          this.curImgHasChecked = this.choseImgs.includes(this.curChoseImg);
        } else {
          this.curImgHasChecked = false;
        }
        console.log("选择的图片", this.choseImgs);
      } catch (err) {
        console.log(err);
      }
    },
    //全屏
    fullScreen(type) {
      if (type == "in") {
        this.measureKey = true;
        this.handleDrawer_img();
      } else {
        // if (this.isDraw) return;
        if (this.isDraw) {
          this.isDraw = false;
        }
        this.measureKey = false;
      }
    },
    //获取上一例检查报告
    beforeReport() {
      const vm = this;
      vm.getChangeReport({
        id: vm.curDocRecord.id,
        type: "before",
      });
      // let curDocRecord = {
      //   ...vm.curDocRecord,
      // };
      // if (vm.curDocRecord.model == "自主模式") {
      //   const form_data = {
      //     ...vm.form1.getFieldsValue(),
      //     birth: vm.birth,
      //   };
      //   curDocRecord = {
      //     ...curDocRecord,
      //     ...form_data,
      //   };
      // }
      // if (!looseEqual(curDocRecord, this.initRecordData)) {
      //   if (this.curDocRecord.state == 4 || this.curDocRecord.state == 6) {
      //     console.log("获取上一例检查报告");
      //     this.getChangeReport({
      //       id: this.curDocRecord.id,
      //       type: "before",
      //     });
      //   } else {
      //     this.$confirm({
      //       title: "提示:",
      //       okText: "是",
      //       cancelText: "否",
      //       autoFocusButton: "ok",
      //       content: () => <div style="color:red;">该报告有改动,是否暂存?</div>,
      //       async onOk() {
      //         vm.Temporarystorage("before");
      //       },
      //       onCancel() {
      //         console.log("获取上一例检查报告");
      //         vm.getChangeReport({
      //           id: vm.curDocRecord.id,
      //           type: "before",
      //         });
      //       },
      //       class: "test",
      //     });
      //   }
      // } else {
      //   console.log("获取上一例检查报告");
      //   vm.getChangeReport({
      //     id: vm.curDocRecord.id,
      //     type: "before",
      //   });
      // }
    },
    //获取下一例检查报告
    afterReport() {
      const vm = this;
      vm.getChangeReport({
        id: vm.curDocRecord.id,
        type: "after",
      });
      // let curDocRecord = {
      //   ...vm.curDocRecord,
      // };
      // if (vm.curDocRecord.model == "自主模式") {
      //   const form_data = {
      //     ...vm.form1.getFieldsValue(),
      //     birth: vm.birth,
      //   };
      //   curDocRecord = {
      //     ...curDocRecord,
      //     ...form_data,
      //   };
      // }
      // if (!looseEqual(curDocRecord, this.initRecordData)) {
      //   if (this.curDocRecord.state == 4 || this.curDocRecord.state == 6) {
      //     console.log("获取上一例检查报告");
      //     this.getChangeReport({
      //       id: this.curDocRecord.id,
      //       type: "after",
      //     });
      //   } else {
      //     this.$confirm({
      //       title: "提示:",
      //       okText: "是",
      //       cancelText: "否",
      //       autoFocusButton: "ok",
      //       content: () => <div style="color:red;">该报告有改动,是否暂存?</div>,
      //       async onOk() {
      //         vm.Temporarystorage("after");
      //       },
      //       onCancel() {
      //         console.log("获取上一例检查报告");
      //         this.getChangeReport({
      //           id: this.curDocRecord.id,
      //           type: "after",
      //         });
      //       },
      //       class: "test",
      //     });
      //   }
      // } else {
      //   console.log("获取上一例检查报告");
      //   this.getChangeReport({
      //     id: this.curDocRecord.id,
      //     type: "after",
      //   });
      // }
    },
    //监听切换报告回调
    getChangeReport(data) {
      const vm = this;
      let index = vm.tableData.findIndex((el) => el.id === data.id);
      if (index === -1) {
        this.$message.error("不能进行切换！");
      } else if (index === 0 && data.type === "before") {
        if (this.currentPage == 1) {
          this.$message.error("已经是第一条检查记录,不能进行切换！");
          console.log("第一个", index);
        } else {
          const page = this.currentPage - 1;
          this.getRecord(page, "before");
        }
      } else if (index === vm.tableData.length - 1 && data.type === "after") {
        console.log(
          "%c [ this.currentPage == Math.ceil(this.total / this.limit ]-2068",
          "font-size:13px; background:pink; color:#bf2c9f;",
          Math.ceil(this.total / this.limit)
        );
        if (this.currentPage == Math.ceil(this.total / this.limit)) {
          console.log("最后一个", index);
          this.$message.error("已经是最后一条检查记录,不能进行切换！");
        } else {
          const page = this.currentPage + 1;
          this.getRecord(page, "after");
        }
      } else {
        if (data.type === "before") {
          let record = vm.tableData[index - 1];
          if (record.state === 0) {
            this.$message.error("上一检查记录不能生成检查报告！");
          } else {
            console.log("record", record);
            this.getReportData(record.id, "", record.patient_sn);
          }
        } else if (data.type === "after") {
          let record = vm.tableData[index + 1];
          if (record.state === 0) {
            this.$message.error("下一检查记录不能生成检查报告！");
          } else {
            console.log("record", record);
            this.getReportData(record.id, "", record.patient_sn);
          }
        }
      }
    },
    //根据page获取数据
    async getRecord(page, dir) {
      try {
        const params = {
          page,
          limit: 10,
        };
        const res = await findRecordAndPatient(this.RECORD_URL, params);
        console.log(
          "%c [ res ]-2081",
          "font-size:13px; background:pink; color:#bf2c9f;",
          res.data.rows
        );
        if (res.code == 200) {
          if (res.data.rows.length > 0) {
            const params = {
              tableData: res.data.rows,
              currentPage: page,
              limit: this.limit,
              total: res.data.total,
            };
            window.localStorage.setItem("tableData", JSON.stringify(params));
            if (dir == "before") {
              this.getReportData(
                res.data.rows[res.data.rows.length - 1].id,
                "",
                res.data.rows[res.data.rows.length - 1].patient_sn
              );
            } else if (dir == "after") {
              this.getReportData(
                res.data.rows[0].id,
                "",
                res.data.rows[res.data.rows.length - 1].patient_sn
              );
            }
          }
        }
      } catch (err) {
        console.log(err);
      }
    },
    //删除图片
    async confirmDelete() {
      try {
        const imgs = JSON.parse(this.curDocRecord.reportimg);
        const newImgs = deleteArrById3(imgs, this.curChoseImg);
        const choseImg = this.curDocRecord.choseImg
          ? JSON.parse(this.curDocRecord.choseImg)
          : [];
        let new_choseImg;
        if (choseImg.length > 0 && choseImg.includes(this.curChoseImg)) {
          new_choseImg = deleteArrById2(choseImg, this.curChoseImg);
        }
        const update_params = {
          reportimg: JSON.stringify(newImgs),
        };
        if (new_choseImg) {
          update_params.choseImg = JSON.stringify(new_choseImg);
        }
        const measureInfo = JSON.parse(this.curDocRecord.measureInfo);
        if (measureInfo.LesionInfo && measureInfo.LesionInfo.length > 0) {
          measureInfo.LesionInfo = delLesionInfo(
            this.curChoseImg,
            measureInfo.LesionInfo
          );
          update_params.measureInfo = JSON.stringify(measureInfo);
        }
        console.log("删除图片前", imgs, "删除图片后newImgs", newImgs);
        const params = {
          id: this.curDocRecord.id,
          patient_sn: this.curDocRecord.patient_sn,
        };
        const res = await updateRecord(this.RECORD_URL, update_params, params);
        if (res.code === 200) {
          //有测量数据
          if (this.measurePoints) {
            this.resetCanvasData();
            this.Caliper_clear();
          }
          this.imgInfoName = "";
          this.previewImg = "";
          this.previewImgShow = false;
          this.getReportData(
            this.curDocRecord.id,
            "update",
            this.curDocRecord.patient_sn
          );
          this.$message.success("删除成功！");
        } else {
          this.$message.console.error("删除失败！");
        }
      } catch (err) {
        console.log(err);
      }
    },
    //暂存报告
    async Temporarystorage(dir) {
      try {
        const vm = this;
        const storageRecord = {
          seen: this.curDocRecord.seen,
          tips: this.curDocRecord.tips,
          choseImg:
            this.choseImgs.length > 0 ? JSON.stringify(this.choseImgs) : "",
          patient_sn: this.curDocRecord.patient_sn
            ? this.curDocRecord.patient_sn
            : "",
          doctor_sn: this.curDocRecord.doctor_sn
            ? this.curDocRecord.doctor_sn
            : "",
          images: this.selectImgs.length,
          normal: this.normal,
        };
        if (this.curDocRecord.model == "自主模式") {
          storageRecord.sNo = this.form1.getFieldValue("sNo");
          storageRecord.name = this.form1.getFieldValue("name");
          storageRecord.sex = this.curDocRecord.sex;
          storageRecord.year = this.year || this.curDocRecord.year;
          storageRecord.birth = this.birth;
          storageRecord.pos = this.curDocRecord.pos;
          const update_params = this.$refs.feature.getFeatureData();
          this.intelligentHasChange();
          console.log("保存测量参数：", update_params);
          if (update_params) {
            if (this.changedImgInfos.length > 0) {
              update_params.LesionInfo = this.updateLesionInfo();
            }
            storageRecord.measureInfo = JSON.stringify(update_params);
          }
        }
        console.log("storageRecord", storageRecord);
        const params = {
          id: vm.curDocRecord.id,
          patient_sn: vm.curDocRecord.patient_sn,
        };
        //暂存报告
        updateRecord(this.RECORD_URL, storageRecord, params)
          .then((res) => {
            if (res.code === 200) {
              vm.$message.success("暂存成功！");
              if (dir == "after" || dir == "before") {
                vm.getChangeReport({
                  id: vm.curDocRecord.id,
                  type: dir,
                });
              } else {
                vm.$EventBus.$emit("updateSelectRecord", storageRecord);
                vm.go2Record();
                addLogInfo(vm.SERVERBASE_URL, {
                  name: vm.userInfo.name,
                  type: "操作",
                  event: "暂存报告",
                });
              }
            } else {
              vm.$message.error(`更新失败!${res.err}`);
            }
          })
          .catch((err) => {
            console.log(err);
          });
      } catch (err) {
        console.log(err);
      }
    },
    //重置数据
    resetData() {
      if (this.curDocRecord) {
        this.curDocRecord.seen = "";
        this.curDocRecord.tips = "";
      }
      this.curDocRecord = "";
      this.selectImgs = [];
      this.selectImgsById = [];
      this.choseImgs = [];
      this.previewImg = "";
      this.imgInfoName = "";
      this.curChoseImg = "";
      this.isSendReport = false;
      const dom = document.querySelector("#report--export");
      if (dom) {
        dom.innerHTML = "";
      }
      window.onafterprint = null;
      this.curVideo = "";
      this.resetCanvasData();
      if (this.watchVideoKey) {
        this.watchVideoKey = false;
      }
      if (this.measureKey) {
        this.measureKey = false;
      }
      this.ownTabIndex = 1;
      this.previewImgShow = false;
      this.userSymTitle = "";
      this.userSymObj = null;
      this.templateType = "public";
      this.usersymptomData = [];
      this.oriReportimg = "";
      this.changedImgInfos = [];
    },
    //返回检查记录页
    go2Record() {
      this.resetData();
      this.$router.push({ name: "home" });
    },
    //选择模板
    onSelect(data, info) {
      if (this.curDocRecord.state === 4 || this.curDocRecord.state === 6) {
        this.$message.warning("已出报告!");
        return;
      }
      const con = info.node._props.dataRef;
      if (con.seen) {
        this.symptomModalInfo_title = con.title;
        this.origin_symptomModalInfo_seen = con.seen.replace(
          /(\n|\r|\r\n|↵)/g,
          "<br/>"
        );
        this.origin_symptomModalInfo_tips = con.tips.replace(
          /(\n|\r|\r\n|↵)/g,
          "<br/>"
        );
        this.symptomModalInfo_seen = con.seen
          .replace(/(\n|\r|\r\n|↵)/g, "<br/>")
          .replace(/{.*?}/g, "_");
        this.symptomModalInfo_tips = con.tips
          .replace(/(\n|\r|\r\n|↵)/g, "<br/>")
          .replace(/{.*?}/g, "_");
        if (!this.symptomActive) {
          this.symptomActive = true;
        }
      }
      info.node.onExpand();
      console.log("模板 seen", data, con.seen);
      console.log("模板 tips", data, con.tips);
    },
    //关闭模板弹窗
    closeReportModal() {
      this.symptomActive = false;
      this.symptomModalInfo_title = "";
      this.symptomModalInfo_seen = "";
      this.symptomModalInfo_tips = "";
    },
    //加载 导入模板数据
    async loadReportSympto() {
      if (!this.curDocRecord.seen && !this.curDocRecord.tips) {
        this.curDocRecord.seen = this.symptomModalInfo_seen.replace(
          /<br\/>/g,
          "\n"
        );
        this.curDocRecord.tips = this.symptomModalInfo_tips.replace(
          /<br\/>/g,
          "\n"
        );
        this.closeReportModal();
      } else {
        this.reportSymptomModalKey = true;
      }
    },
    //不覆盖
    noCover() {
      if (this.curDocRecord.model == "远程模式") {
        this.curDocRecord.seen =
          this.curDocRecord.seen === ""
            ? this.symptomModalInfo_seen.replace(/<br\/>/g, "\n")
            : this.curDocRecord.seen +
              "\n" +
              this.symptomModalInfo_seen.replace(/<br\/>/g, "\n");
        this.curDocRecord.tips =
          this.curDocRecord.tips === "" || this.curDocRecord.tips === null
            ? this.symptomModalInfo_tips.replace(/<br\/>/g, "\n")
            : this.curDocRecord.tips +
              "\n" +
              this.symptomModalInfo_tips.replace(/<br\/>/g, "\n");
      } else if (this.curDocRecord.model == "自主模式") {
        this.curDocRecord.seen =
          this.curDocRecord.seen === ""
            ? this.symptomModalInfo_seen.replace(/<br\/>/g, "\n")
            : this.curDocRecord.seen +
              "\n" +
              this.symptomModalInfo_seen.replace(/<br\/>/g, "\n");
        this.curDocRecord.tips =
          this.curDocRecord.tips === "" || this.curDocRecord.tips === null
            ? this.symptomModalInfo_tips.replace(/<br\/>/g, "\n")
            : this.curDocRecord.tips +
              "\n" +
              this.symptomModalInfo_tips.replace(/<br\/>/g, "\n");
        this.origin_symptomModalInfo_seen =
          this.origin_symptomModalInfo_seen + this.origin_symptomModalInfo_seen;
      }
      this.reportSymptomModalKey = false;
      this.symptomActive = false;
    },
    //覆盖
    Cover() {
      if (this.curDocRecord.model == "远程模式") {
        this.curDocRecord.seen = this.symptomModalInfo_seen.replace(
          /<br\/>/g,
          "\n"
        );
        this.curDocRecord.tips = this.symptomModalInfo_tips.replace(
          /<br\/>/g,
          "\n"
        );
      } else if (this.curDocRecord.model == "自主模式") {
        this.curDocRecord.seen = this.symptomModalInfo_seen.replace(
          /<br\/>/g,
          "\n"
        );
        this.curDocRecord.tips = this.symptomModalInfo_tips.replace(
          /<br\/>/g,
          "\n"
        );
      }

      this.curDocRecord.seenData = [];
      this.reportSymptomModalKey = false;
      this.symptomActive = false;
    },
    momenthandle(val) {
      return moment(val).format("YYYY-MM-DD HH:mm:ss");
    },
    //初始化画布
    initCanvas() {
      this.canvas = document.querySelector("#my-canvas");
      const root = document.querySelector(".report--measure--canvas");
      const root_w = root.offsetWidth;
      const root_h = root.offsetHeight;
      this.canvas.width = root_w;
      this.canvas.height = root_h;
      this.width = root_w;
      this.height = root_h;
      this.ctx = this.canvas.getContext("2d");
      this.ctx.font = "21px Arial";
      this.ctx.fillStyle = "#00ffff";
      this.ctx.strokeStyle = "aqua";
      this.ctx.lineWidth = 2;
      this.ctx.setLineDash([3, 3]);
    },
    //重置CanvasData
    resetCanvasData() {
      this.isDraw = false;
      this.measurePoints = [];
      this.temporaryImgData = null;
      this.imgData = null;
      this.fristClick = false;
      this.secondClick = false;
      this.chosePointIndex = null;
      this.saveMeasureKey = false;
    },
    //测量处理函数
    measureHandle() {
      if (this.curDocRecord.state == 4) {
        return;
      }
      if (this.curDocRecord.state == 6) {
        return;
      }
      if (!this.canMeasure) {
        return;
      }
      if (this.fristClick) {
        return;
      }
      if (!this.measureKey) {
        this.measureKey = true;
      }
      setTimeout(() => {
        this.Caliper_start();
      }, 300);
    },
    //开始或停止测距
    async Caliper_start() {
      try {
        if (!this.isDraw) {
          this.isDraw = true;
          if (this.canvas) {
            this.canvas.addEventListener("mousedown", this.onMouseDown);
          }
          //判断鼠标移动中是否停留到画过的线上
          if (this.measurePoints.length > 0 && this.canvas) {
            this.canvas.addEventListener("mousemove", this.onMeasuredMove);
          }
          //如果没有测量数据了就不用监听鼠标移动
          if (this.measurePoints.length == 0) {
            this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
          }
        } else {
          this.canvas.removeEventListener("mousedown", this.onMouseDown);
          this.canvas.removeEventListener("mousemove", this.onMouseMove);
          this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
          this.isDraw = false;
          this.fristClick = false;
          this.secondClick = false;
          this.temporaryImgData = null;
        }
      } catch (err) {
        console.log(err);
      }
    },
    //获取真实的距离
    getRealDIs(p1, p2, curImgParams) {
      try {
        if (!curImgParams) {
          return px2cm(distance(p1, p2));
        } else if (
          curImgParams.usMode != "4" &&
          curImgParams.disPerPixel != "-1.000000"
        ) {
          const oriImg = document.querySelector(
            ".report--measure--canvas .measureImg"
          );
          const oriImgW = oriImg.offsetWidth;
          const oriImgH = oriImg.offsetHeight;
          console.log(
            "%c [ 鼠标坐标 ]-2955",
            "font-size:13px; background:pink; color:#bf2c9f;",
            p1,
            p2
          );
          console.log(
            "%c [ 原始图片宽高 ]-2955",
            "font-size:13px; background:pink; color:#bf2c9f;",
            oriImgW,
            oriImgH
          );
          const real_x1w = (p1.x / oriImgW) * curImgParams.imageW;
          const real_x1h = (p1.y / oriImgH) * curImgParams.imageH;
          const real_x2w = (p2.x / oriImgW) * curImgParams.imageW;
          const real_x2h = (p2.y / oriImgH) * curImgParams.imageH;
          console.log(
            "%c [ 真实坐标 ]-2962",
            "font-size:13px; background:pink; color:#bf2c9f;",
            real_x1w,
            real_x1h,
            real_x2w,
            real_x2h
          );
          const real_dis =
            distance(
              { x: real_x1w, y: real_x1h },
              { x: real_x2w, y: real_x2h }
            ) *
            curImgParams.disPerPixel *
            100;
          console.log(
            "%c [ 真实距离 ]-2964",
            "font-size:13px; background:pink; color:#bf2c9f;",
            real_dis
          );
          return real_dis.toFixed(2);
        } else if (curImgParams.usMode == "4") {
          return px2cm(distance(p1, p2));
        } else {
          return px2cm(distance(p1, p2));
        }
      } catch (err) {
        console.log(err);
      }
    },
    //监听鼠标按下
    onMouseDown(event) {
      if (event.button == 0) {
        //第一次点击
        if (!this.fristClick) {
          //保存临时canvas数据
          this.temporaryImgData = this.ctx.getImageData(
            0,
            0,
            this.width,
            this.height
          );
          this.startX = event.offsetX;
          this.startY = event.offsetY;
          this.fristClick = true;
          this.secondClick = false;
          if (this.canvas) {
            this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
          }
          if (this.canvas && this.fristClick) {
            this.canvas.addEventListener("mousemove", this.onMouseMove);
          }
        } else {
          if (this.startX == event.offsetX && this.startY == event.offsetY) {
            return;
          }
          //若测量数据长度大于10
          if (this.measurePoints.length > 15) {
            this.measurePoints.shift();
            this.drawAllLines(this.measurePoints);
          }
          //第二次点击
          this.canvas.removeEventListener("mousemove", this.onMouseMove);
          this.endX = event.offsetX;
          this.endY = event.offsetY;
          this.real_dis = this.getRealDIs(
            { x: this.startX, y: this.startY },
            { x: this.endX, y: this.endY },
            this.curImgParams
          );
          //将该条线段的点放入集合
          const point_param = {
            id: uuidv4(),
            p1: { x: this.startX, y: this.startY },
            p2: { x: this.endX, y: this.endY },
            flag: 0,
            dis: this.real_dis,
          };
          this.measurePoints.push(point_param);
          this.drawSecond(this.endX, this.endY, this.measurePoints.length);
          this.imgData = this.ctx.getImageData(0, 0, this.width, this.height);
          this.fristClick = false;
          this.secondClick = true;
          if (this.canvas && this.secondClick) {
            this.canvas.addEventListener("mousemove", this.onMeasuredMove);
          }
        }
      } else if (event.button == 2) {
        if (this.fristClick) {
          console.log("第一次点击后鼠标右键!");
          this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
          this.canvas.removeEventListener("mousemove", this.onMouseMove);
          this.fristClick = false;
          this.ctx.putImageData(this.temporaryImgData, 0, 0);
        }
        if (this.secondClick && typeof this.chosePointIndex == "number") {
          console.log("第二次点击后鼠标右键!", this.chosePointIndex);
          this.measurePoints.splice(this.chosePointIndex, 1);
          this.drawAllLines(this.measurePoints);
          this.imgData = this.ctx.getImageData(0, 0, this.width, this.height);
          //如果没有测量数据了就不用监听鼠标移动
          if (this.measurePoints.length == 0) {
            this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
          }
        }
        if (
          !this.fristClick &&
          !this.secondClick &&
          this.measurePoints.length > 0 &&
          typeof this.chosePointIndex == "number"
        ) {
          console.log("啥都没点按右键", this.chosePointIndex);
          this.measurePoints.splice(this.chosePointIndex, 1);
          this.drawAllLines(this.measurePoints);
          this.imgData = this.ctx.getImageData(0, 0, this.width, this.height);
          //如果没有测量数据了就不用监听鼠标移动
          if (this.measurePoints.length == 0) {
            this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
          }
        }
      } else if (event.button == 1) {
        console.log("鼠标滚轮!");
      }
    },
    //监听鼠标移动
    onMouseMove(e) {
      if (e.offsetX) {
        this.draw(e.offsetX, e.offsetY);
      }
    },
    //监听测量后鼠标移动
    onMeasuredMove(e) {
      try {
        const i = this.isPointOnStroke(
          e.offsetX,
          e.offsetY,
          this.measurePoints
        );
        if (typeof i == "number") {
          this.chosePointIndex = i;
        } else {
          this.chosePointIndex = null;
        }
      } catch (err) {
        console.log(err);
      }
    },
    //判断点是否在线上
    isPointOnStroke(px, py, lines) {
      try {
        // 可接受（偏移）范围
        const offset = 10;
        let real_i = "";
        for (var i = 0; i < lines.length; i++) {
          var p1 = lines[i].p1; // 直线起点
          var p2 = lines[i].p2; // 直线终点
          var flag = 0; // 1 - 点中
          var minX = Math.min(p1.x, p2.x); // 较小的X轴坐标值
          var maxX = Math.max(p1.x, p2.x); // 较大的X轴坐标值
          var minY = Math.min(p1.y, p2.y); // 较小的Y轴坐标值
          var maxY = Math.max(p1.y, p2.y); // 较大的Y轴坐标值

          if (p1.y === p2.y) {
            // 水平线
            if (
              px >= minX &&
              px <= maxX &&
              py >= minY - offset &&
              py <= maxY + offset
            ) {
              flag = 1;
              real_i = i;
            }
          } else if (p1.x === p2.x) {
            // 垂直线
            if (
              py >= minY &&
              py <= maxY &&
              px >= minX - offset &&
              px <= maxX + offset
            ) {
              flag = 1;
              real_i = i;
            }
          } else {
            // 斜线 (先判断点是否进入可接受大范围(矩形)，然后再根据直线上的交叉点进行小范围比较)
            if (
              px >= minX &&
              px <= maxX &&
              py >= minY - offset &&
              py <= maxY + offset
            ) {
              //求Y轴坐标
              //方法1：根据tanθ= y/x = y1/x1, 即y = (y1/x1)*x  (该方法有局限性，垂直线(p2.x - p1.x)=0，不能用)
              //var y = ((p2.y - p1.y) / (p2.x - p1.x)) * (px - p1.x);
              //方法2：先求弧度hudu，根据cosθ=x/r, r=x/cosθ,求得r，再根据sinθ=y/r, y=sinθ*r, 求得y
              var hudu = Math.atan2(p2.y - p1.y, p2.x - p1.x); // 直线的弧度(倾斜度)
              // 用三角函数计出直线上的交叉点
              var r = (px - p1.x) / Math.cos(hudu); // 直角三角形的斜边（或理解成圆的半径）
              var y = Math.sin(hudu) * r; // Y轴坐标
              var p = { x: px, y: p1.y + y }; // 直线上的交叉点
              if (
                Math.abs(px - p.x) <= offset &&
                Math.abs(py - p.y) <= offset
              ) {
                flag = 1; // 1 - 点中
                real_i = i;
              }
            }
          }
          if (flag === 1) {
            // lines[i].flag = (lines[i].flag + 1) % 2; // 0、1切换
            lines[i].flag = 1; // 0、1切换
          } else {
            lines[i].flag = 0;
          }
        }
        this.drawAllLines(lines);
        return real_i;
      } catch (err) {
        console.log(err);
      }
    },
    //重画线
    drawAllLines(lines) {
      try {
        if (this.ctx && this.canvas) {
          // 清空画布
          this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
          // 画出逐条线
          for (var i = 0; i < lines.length; i++) {
            var color = lines[i].flag === 1 ? "aqua" : "#ffffff";
            this.drawLine(this.ctx, lines[i].p1, lines[i].p2, i + 1, color);
          }
        }
      } catch (err) {
        console.log(err);
      }
    },
    //画单条线
    drawLine(ctx, p1, p2, dis, color) {
      try {
        this.ctx.fillStyle = color;
        ctx.strokeStyle = color;
        let x, y;
        if (p1.x > p2.x) {
          x = p1.x + 10;
        } else {
          x = p1.x - 20;
        }
        y = p1.y;
        ctx.beginPath();
        ctx.moveTo(p1.x, p1.y);
        ctx.lineTo(p2.x, p2.y);
        ctx.stroke();
        ctx.beginPath();
        ctx.fillText(dis, x, y);
        this.ctx.closePath();
      } catch (err) {
        console.log(err);
      }
    },
    //清除画布
    Caliper_clear() {
      if (this.ctx) {
        this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
      }
    },
    //画虚线
    draw(x, y) {
      if (this.ctx) {
        this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
        if (this.imgData) {
          this.ctx.putImageData(this.imgData, 0, 0);
        }
        this.ctx.fillStyle = "#00ffff";
        this.ctx.strokeStyle = "aqua";
        this.ctx.beginPath();
        this.ctx.moveTo(this.startX, this.startY);
        this.ctx.lineTo(x, y);
        this.ctx.stroke();
        this.ctx.closePath();
      }
    },
    //第二次点击左键时标注
    drawSecond(x, y, dis) {
      if (this.ctx) {
        let x_show, y_show;
        if (this.startX > x) {
          x_show = this.startX + 10;
        } else {
          x_show = this.startX - 20;
        }
        y_show = this.startY;
        this.ctx.fillStyle = "#ffffff";
        this.ctx.strokeStyle = "#ffffff";
        this.ctx.beginPath();
        this.ctx.moveTo(this.startX, this.startY);
        this.ctx.lineTo(x, y);
        this.ctx.stroke();
        this.ctx.beginPath();
        this.ctx.fillText(`${dis}`, x_show, y_show);
        this.ctx.closePath();
      }
    },
    //测量后另存图片
    async confirmSave(cb, type) {
      try {
        if (this.curDocRecord.state == 4 || this.curDocRecord.state == 6) {
          this.$message.warning("已出报告!");
          return;
        }
        if (this.measurePoints.length == 0) {
          return;
        }
        if (this.saveMeasureKey) {
          return;
        }
        this.saveMeasureKey = true;
        const save_img = await this._barPhotoCanvas();
        const save_imgBlob = convertBase64UrlToBlob3(save_img);
        const cur_imgInfo = this.images[this.curImgIndex];
        if (save_imgBlob && cur_imgInfo) {
          const form_data = new FormData();
          form_data.append("Data", save_imgBlob);
          const urlInfo = getIpAndPortMore(cur_imgInfo.url, 41025); //41023
          form_data.append("SubDir", urlInfo.SubDir);
          form_data.append("FileName", urlInfo.FileName);
          const baseUrl = urlInfo.baseUrl;
          const post_param = {
            StorageIP: urlInfo.ip,
            SN: this.curDocRecord.patient_sn,
            RecordID: this.curDocRecord.id,
            SubDir: urlInfo.SubDir,
            FileName: urlInfo.FileName,
          };
          console.log("解析url", urlInfo);
          console.log("上传的图片信息", post_param);
          console.log("baseUrl", baseUrl);
          //测量图片上传到服务器
          const resp = await uploadMeasureImage(baseUrl, form_data);
          if (resp.code == 200) {
            console.log("推送测量图像数据成功", resp.data);
            //添加测量图像
            const recordRes = await addMeasureImage(
              this.RECORD_URL,
              post_param
            );
            if (recordRes.code == 200 && recordRes.data) {
              //保持智能结构化信息
              await this.updateRecoedLesionInfo(`${urlInfo.param_id}`);
              this.getReportData(
                this.curDocRecord.id,
                "update",
                this.curDocRecord.patient_sn
              );
              this.resetCanvasData();
              this.Caliper_clear();
              this.$message.success("另存成功");
              //回调函数
              if (cb && typeof cb == "function") {
                cb();
              }
              //保存后退出
              if (type == "out") {
                this.measureKey = false;
              }
            } else {
              this.$message.error(`测量图片上传到服务器失败,${recordRes.msg}`);
              this.saveMeasureKey = false;
            }
          } else {
            this.$message.error(`测量图片上传到服务器失败,${resp.msg}`);
            this.saveMeasureKey = false;
          }
        } else {
          console.log("没有图片信息");
        }
      } catch (err) {
        console.log(err);
        this.saveMeasureKey = false;
      }
    },
    //保存图片后到下一张图片
    confirmSaveAndPre(dir) {
      try {
        console.log("保存图片后到下一张图片", dir);
        this.confirmSave(this.handleGoPreview(dir));
      } catch (err) {
        console.log(err);
      }
    },
    //点下一张图片取消保存
    cancelSaveAndPre(dir) {
      try {
        console.log(dir);
        this.handleGoPreview(dir);
        this.resetCanvasData();
        this.Caliper_clear();
        this.canvas.removeEventListener("mousedown", this.onMouseDown);
        this.canvas.removeEventListener("mousemove", this.onMouseMove);
        this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
      } catch (err) {
        console.log(err);
      }
    },
    //退出全屏并且取消
    cancelSaveAndOut() {
      this.resetCanvasData();
      this.Caliper_clear();
      this.canvas.removeEventListener("mousedown", this.onMouseDown);
      this.canvas.removeEventListener("mousemove", this.onMouseMove);
      this.canvas.removeEventListener("mousemove", this.onMeasuredMove);
      this.measureKey = false;
    },
    //退出全屏保存并退出测量
    confirmSaveAndOut() {
      try {
        console.log("退出全屏并保存");
        this.confirmSave("", "out");
      } catch (err) {
        console.log(err);
      }
    },
    //测量后截图
    _barPhotoCanvas() {
      return new Promise((resolve) => {
        try {
          const reportMeasure = document.querySelector(
            ".report--measure--canvas"
          );
          if (reportMeasure) {
            html2canvas(reportMeasure, {
              useCORS: true,
              backgroundColor: null,
              allowTaint: true,
              ignoreElements: (element) => {
                if (element.tagName.toLowerCase() === "iframe") {
                  return element;
                }
                return false;
              },
            }).then(async (canvas) => {
              const img = canvas.toDataURL("image/jpeg", 1);
              resolve(img);
            });
          }
        } catch (err) {
          console.log(err);
        }
      });
    },
    //切换图片
    imgTypeChange(type) {
      try {
        if (type == "all") {
          this.images.forEach((item) => {
            item.visable = true;
          });
        } else if (type == "standard") {
          this.images.forEach((item) => {
            if (item.status === "normal") {
              item.visable = true;
            } else {
              item.visable = false;
            }
          });
        } else if (type == "tubrcle") {
          this.images.forEach((item) => {
            if (item.status === "lesion") {
              item.visable = true;
            } else {
              item.visable = false;
            }
          });
        } else if (type == "measure") {
          if(this.curDocRecord.pos == "颈动脉"){
            this.images.forEach((item) => {
              if ((item.status === "cali" || item.type == "measure") && arteryCaliShow.includes(item.info)) {
                if(item.id.includes("19-cali-memUp") || item.id.includes("33-cali-memUp")){
                  item.visable = false;
                }else{
                  item.visable = true;
                }
              } else {
                item.visable = false;
              }
            });
          }else{
            this.images.forEach((item) => {
              if (item.status === "cali" || item.type == "measure") {
                item.visable = true;
              } else {
                item.visable = false;
              }
            });
          }
        }
        this.showImgType = type;
        const showArr = [];
        this.images.forEach((i,index)=>{
          if(i.visable){
            showArr.push({...i,oriIndex:index})
          }
        })
        this.showImgArr = showArr;
      } catch (err) {
        console.log(err);
      }
    },
    //查看视频
    watchVideo(url, id) {
      try {
        console.log("查看视频", this.videoS);
        if (this.videoS.length > 0) {
          this.curVideo = url;
          this.curVideoId = id;
          this.watchVideoKey = true;
          this.handleDrawer();
        } else {
          this.$message.warning("没有视频！");
        }
      } catch (err) {
        console.log(err);
      }
    },
    //切换视频
    videoByDir(dir) {
      try {
        const curVideoIndex = this.videoS.findIndex((item) => {
          return item.url == this.curVideo;
        });
        if (curVideoIndex == -1) {
          return;
        }
        if (dir == "right") {
          if (curVideoIndex == this.videoS.length - 1) {
            this.$message.warning("最后一个视频!");
            return;
          }
          this.curVideo = this.videoS[curVideoIndex + 1].url;
          this.curVideoId = this.videoS[curVideoIndex + 1].id;
        } else if (dir == "left") {
          if (curVideoIndex == 0) {
            this.$message.warning("第一个视频!");
            return;
          }
          this.curVideo = this.videoS[curVideoIndex - 1].url;
          this.curVideoId = this.videoS[curVideoIndex - 1].id;
        }
        this.$nextTick(() => {
          this.$refs.videocomp.initVideo();
        });
      } catch (err) {
        console.log(err);
      }
    },
    //关闭视频
    chosevideo() {
      try {
        console.log("关闭视频");
        this.watchVideoKey = false;
      } catch (err) {
        console.log(err);
      }
    },
    //实现textarea光标在_上切换
    onTab(e) {
      const textarea = e.target;
      const start = textarea.selectionStart;
      let nextUnderscore;
      if (this.focusWho == "seen") {
        nextUnderscore = this.curDocRecord.seen.indexOf("_", start);
      } else if (this.focusWho == "tips") {
        nextUnderscore = this.curDocRecord.tips.indexOf("_", start);
      }
      if (nextUnderscore === -1) {
        if (this.focusWho == "seen") {
          nextUnderscore = this.curDocRecord.seen.indexOf("_");
          this.selectionStart_seen = textarea.selectionEnd = nextUnderscore + 1;
        } else if (this.focusWho == "tips") {
          nextUnderscore = this.curDocRecord.tips.indexOf("_");
          this.selectionStart_tips = textarea.selectionEnd = nextUnderscore + 1;
        }
        textarea.selectionStart = textarea.selectionEnd = nextUnderscore + 1;
      }
      if (nextUnderscore !== -1) {
        e.preventDefault();
        textarea.selectionStart = textarea.selectionEnd = nextUnderscore + 1;
        if (this.focusWho == "seen") {
          this.selectionStart_seen = textarea.selectionEnd = nextUnderscore + 1;
        } else if (this.focusWho == "tips") {
          this.selectionStart_tips = textarea.selectionEnd = nextUnderscore + 1;
        }
      }
    },
    //记录鼠标位置
    handleonClick(type) {
      try {
        this.focusWho = type;
        if (this.focusWho == "seen") {
          let textarea;
          if (this.curDocRecord.model == "远程模式") {
            textarea = this.$refs.seen_remote;
          } else {
            textarea = this.$refs.seen;
          }
          this.selectionStart_seen = textarea.selectionStart;
          console.log("seen start:", this.selectionStart_seen);
        } else if (this.focusWho == "tips") {
          let textarea;
          if (this.curDocRecord.model == "远程模式") {
            textarea = this.$refs.tips_remote;
          } else {
            textarea = this.$refs.tips;
          }
          this.selectionStart_tips = textarea.selectionStart;
          console.log("tips start:", this.selectionStart_tips);
        }
      } catch (error) {
        console.log("handleonClick:", error);
      }
    },
    addTag(text) {
      try {
        console.log("addTag val:", text);
        if (this.focusWho == "seen") {
          let textarea;
          if (this.curDocRecord.model == "远程模式") {
            textarea = this.$refs.seen_remote;
          } else {
            textarea = this.$refs.seen;
          }
          console.log("seen start:", this.selectionStart_seen);
          if (this.curDocRecord.seen && this.curDocRecord.seen.length > 0) {
            this.curDocRecord.seen =
              this.curDocRecord.seen.substring(0, this.selectionStart_seen) +
              text +
              this.curDocRecord.seen.substring(this.selectionStart_seen);
          } else {
            this.curDocRecord.seen = text;
          }
          this.$nextTick(() => {
            textarea.focus();
            textarea.selectionStart = this.selectionStart_seen + text.length;
            textarea.selectionEnd = this.selectionStart_seen + text.length;
            this.selectionStart_seen = this.selectionStart_seen + text.length;
          });
        } else if (this.focusWho == "tips") {
          let textarea;
          if (this.curDocRecord.model == "远程模式") {
            textarea = this.$refs.tips_remote;
          } else {
            textarea = this.$refs.tips;
          }
          console.log("tips start:", this.selectionStart_tips);
          if (this.curDocRecord.tips && this.curDocRecord.tips.length > 0) {
            this.curDocRecord.tips =
              this.curDocRecord.tips.substring(0, this.selectionStart_tips) +
              text +
              this.curDocRecord.tips.substring(this.selectionStart_tips);
          } else {
            this.curDocRecord.tips = text;
          }
          this.$nextTick(() => {
            textarea.focus();
            textarea.selectionStart = this.selectionStart_tips + text.length;
            textarea.selectionEnd = this.selectionStart_tips + text.length;
            this.selectionStart_tips = this.selectionStart_tips + text.length;
          });
        }
      } catch (error) {
        console.log("addTag err:", error);
      }
    },
    //获取默认模板
    async getSymptomByTitle(pos, hasLesion) {
      let title = getSymptomTitleByPos(pos, hasLesion);
      const res = await getSymptomByTitle(this.SERVERBASE_URL, {
        title: title,
      });
      return res.data;
    },
    findOriginSeen(allSym) {
      try {
        if (!allSym) {
          return;
        }
        if (allSym.length > 0) {
          for (let i = 0; i < allSym.length; i++) {
            const Symptoms = allSym[i].Symptoms;
            if (Symptoms.length > 0) {
              for (let j = 0; j < Symptoms.length; j++) {
                const aitem = Symptoms[j];
                const originSeenW = this.curDocRecord.seen.slice(0, 2);
                if (aitem.seen.includes(originSeenW)) {
                  this.origin_symptomModalInfo_seen = aitem.seen;
                  break;
                }
              }
            }
          }
        }
      } catch (error) {
        console.log("findOriginSeen", error);
      }
    },
    //判断智能结构化信息是否改变并且添加到改动中
    intelligentHasChange() {
      try {
        const isChanges = this.$refs.intelligent.isChanges();
        if (isChanges) {
          const changeImgInfo = this.$refs.intelligent.getIntelligentVal();
          const findIndex = this.changedImgInfos.findIndex(
            (item) => item.param_id == changeImgInfo.param_id
          );
          if (findIndex != -1) {
            this.changedImgInfos[findIndex] = changeImgInfo;
          } else {
            this.changedImgInfos.push(changeImgInfo);
          }
          console.log("是否有改动", isChanges, "findIndex", findIndex);
          console.log("changedImgInfos", this.changedImgInfos);
          this.oriReportimg = this.oriReportimg.map((item) => {
            if (item.param_id === changeImgInfo.param_id) {
              return { ...item, ...changeImgInfo };
            }
            return item;
          });
        } else {
          console.log("没有改动", isChanges);
        }
      } catch (error) {
        console.log("intelligentHasChange", error);
      }
    },
    //更新easureInfo中LesionInfo字段
    updateLesionInfo(param_id) {
      try {
        let new_LesionInfo = [];
        if (this.curDocRecord.measureInfo) {
          const measureInfo = JSON.parse(this.curDocRecord.measureInfo);
          const LesionInfo = measureInfo.LesionInfo;
          console.log("原始LesionInfo", LesionInfo);
          console.log("保存的改动 this.changedImgInfos", this.changedImgInfos);
          if (LesionInfo) {
            new_LesionInfo = LesionInfo;
            this.changedImgInfos.forEach((i) => {
              const findIndex = LesionInfo.findIndex(
                (item) => item.param_id == i.param_id
              );
              if (findIndex != -1) {
                new_LesionInfo[findIndex] = i;
              } else {
                new_LesionInfo.push(i);
              }
            });
          } else {
            new_LesionInfo = this.changedImgInfos;
          }
        } else {
          new_LesionInfo = this.changedImgInfos;
        }
        if (param_id) {
          const measureData = this.$refs.intelligent.getIntelligentVal();
          const sameItem_index = new_LesionInfo.findIndex(
            (item) => item.param_id == measureData.param_id
          );
          if (sameItem_index != -1) {
            console.log("有测量数据 same_item", sameItem_index);
            new_LesionInfo.splice(sameItem_index, 1);
            measureData.param_id = param_id;
            new_LesionInfo.push(measureData);
          } else {
            console.log("没有有测量数据 same_item", sameItem_index);
            measureData.param_id = param_id;
            new_LesionInfo.push(measureData);
          }
        }
        console.log("最新new_LesionInfo", new_LesionInfo);
        return new_LesionInfo;
      } catch (err) {
        console.log("updateLesionInfo", err);
      }
    },
    //更新检查记录中measureInfo中LesionInfo字段
    async updateRecoedLesionInfo(param_id) {
      try {
        return new Promise((resolve, reject) => {
          let storageRecord;
          const vm = this;
          this.intelligentHasChange();
          if (this.curDocRecord.measureInfo) {
            const measureInfo = JSON.parse(this.curDocRecord.measureInfo);
            measureInfo.LesionInfo = this.updateLesionInfo(param_id);
            storageRecord = { measureInfo: JSON.stringify(measureInfo) };
          } else {
            storageRecord = {};
            storageRecord.measureInfo = JSON.stringify({
              LesionInfo: this.updateLesionInfo(param_id),
            });
          }
          const params = {
            id: vm.curDocRecord.id,
            patient_sn: vm.curDocRecord.patient_sn,
          };
          //更新检查记录状态
          updateRecord(this.RECORD_URL, storageRecord, params)
            .then((res) => {
              if (res.code === 200) {
                console.log("更新LesionInfo成功!");
                resolve("更新LesionInfo成功!");
              } else {
                console.log("更新LesionInfo失败!");
                reject("更新LesionInfo失败!");
              }
            })
            .catch((err) => {
              console.log(err);
            });
        });
      } catch (err) {
        console.log("updateRecoedLesionInfo", err);
      }
    },
    setIntelligentOriVal(param_id) {
      try {
        const OriVal = this.oriReportimg.find(
          (item) => item.param_id == param_id
        );
        console.log("setIntelligentOriVal OriVal", OriVal);
        if (OriVal) {
          const info = { ...OriVal };
          delete info.record_id;
          delete info.type;
          delete info.url;
          this.$refs.intelligent.initIntelligentVal({ ...info });
        }
      } catch (e) {
        console.log("setIntelligentVal err", e);
      }
    },
    //缩小
    reduceImg() {
      this.previewImgShow = false;
      this.curImgIndex = "";
      this.curChoseImg = "";
      if (this.curImgHasChecked) {
        this.curImgHasChecked = false;
      }
    },
    //初始化图片区域页数
    initImgPages() {
      try {
        let grupNum = 4;
        if (this.curDocRecord.model == "远程模式") {
          grupNum = 3;
        }
        if (typeof this.curImgIndex == "number") {
          this.imgCurPage = Math.floor(this.curImgIndex / grupNum) + 1;
        } else {
          this.imgCurPage = 1;
        }
        if (this.images.length > 4) {
          this.imgPages = Math.ceil(this.images.length / grupNum);
        } else {
          this.imgPages = 1;
        }
        console.log(
          "图片区域页数",
          this.imgPages,
          "当前所在页码",
          this.imgCurPage
        );
      } catch (error) {
        console.log("initImgPages error", error);
      }
    },
    goNextImgPageByDir(dir) {
      try {
        if (dir == "left") {
          if (this.imgCurPage < 1) {
            this.imgCurPage = 1;
          }
          if (this.imgCurPage == 1) {
            this.$message.warning("当前为第一页!");
            return;
          }
          this.imgCurPage--;
        } else if (dir == "right") {
          if (this.imgCurPage > this.imgPages) {
            this.imgCurPage = this.imgPages;
          }
          if (this.imgCurPage == this.imgPages) {
            this.$message.warning("当前为最后一页!");
            return;
          }
          this.imgCurPage++;
        }
        let moveDis = 1108;
        if (this.curDocRecord.model == "远程模式") {
          moveDis = 831;
        }
        let left = (this.imgCurPage - 1) * moveDis;
        console.log("goNextImgPageByDir", this.imgCurPage, left);
        $(".report--checkbox--wrap").animate({ scrollLeft: left });
      } catch (error) {
        console.log("goNextImgPageByDir error", error);
      }
    },
    //处理扫查合格率
    async handleQua() {
      this.diagnosis = false;
      this.recognition = false;
      // if (this.qualification) {
      //   this.qualification = false;
      //   return;
      // }
      this.qualification = true;
      if (this.forms.length > 0) {
        const target = this.forms.find((item) => item.evaluationID == 0);
        const res = await getAssessById(this.RECORD_URL, { id: target.id });
        console.log("扫查合格率", res.data.evaluationResult);
        console.log("this.curDocRecord.pos",this.curDocRecord.pos);
        if (res.code == 200) {
          if (res.data.evaluationResult) {
            const val = JSON.parse(res.data.evaluationResult);
            console.log("val", val);
            if (this.curDocRecord.pos == "腹部") {
              this.$EventBus.$emit("qua_initOldResult", val);
            } else {
              this.$EventBus.$emit(
                "qua_initOldResult",
                val[this.curDocRecord.pos]
              );
            }
          }
        }
      }
    },
    //处理标准切面识别率
    async handleRec() {
      this.qualification = false;
      this.diagnosis = false;
      // if (this.recognition) {
      //   this.recognition = false;
      //   return;
      // }
      this.recognition = true;
      if (this.forms.length > 0) {
        const target = this.forms.find((item) => item.evaluationID == 1);
        const res = await getAssessById(this.RECORD_URL, { id: target.id });
        console.log("标准切面识别率", res.data.evaluationResult);
        if (res.code == 200) {
          if (res.data.evaluationResult) {
            const val = JSON.parse(res.data.evaluationResult);
            if (this.curDocRecord.pos == "腹部") {
              this.$EventBus.$emit("rec_initOldResult", val);
            } else {
              this.$EventBus.$emit(
                "rec_initOldResult",
                val[this.curDocRecord.pos]
              );
            }
          }
        }
      }
    },
    //处理诊断一致性
    async handleDia() {
      this.qualification = false;
      this.recognition = false;
      // if (this.diagnosis) {
      //   this.diagnosis = false;
      //   return;
      // }
      this.diagnosis = true;
      if (this.forms.length > 0) {
        const target = this.forms.find((item) => item.evaluationID == 2);
        const res = await getAssessById(this.RECORD_URL, { id: target.id });
        console.log("诊断一致性", res.data.evaluationResult);
        if (res.code == 200) {
          if (res.data.evaluationResult) {
            const val = JSON.parse(res.data.evaluationResult);
            if (this.curDocRecord.pos == "腹部") {
              this.$EventBus.$emit("dia_initOldResult", val);
            } else {
              this.$EventBus.$emit(
                "dia_initOldResult",
                val[this.curDocRecord.pos]
              );
            }
          }
        }
      }
    },
    handleDrawer() {
      if (this.userInfo.level == 6) {
        if (this.qualification) {
          this.handleQua();
        } else if (this.recognition) {
          this.handleRec();
        } else {
          this.handleQua();
        }
      } else if (this.userInfo.level == 7) {
        if (this.blindReview) {
          this.handleDia();
        } else {
          if(!this.hasQua){
            this.handleQua();
          }
        }
      }
    },
    handleDrawer_img() {
      if (this.userInfo.level == 6) {
        this.handleRec();
      } else if (this.userInfo.level == 7) {
        if (this.blindReview) {
          this.handleDia();
        } else {
          this.handleQua();
        }
      }
    },
    //评价结果提交
    async assessSubmit(type) {
      if (type == "qualification") {
        const res = this.$refs.Qualification.getResult();
        if (this.forms.length > 0) {
          const target = this.forms.find((item) => item.evaluationID == 0);
          console.log("target", target, "评价结果", res);
          if (res && Object.keys(target).length > 0) {
            const parmas = {
              id: target.id,
              evaluationResult: JSON.stringify(res),
            };
            const submit_res = await updateAssess(this.RECORD_URL, parmas);
            if (submit_res.code == 200) {
              this.qualification = false;
              this.$message.success("评价成功!");
              addLogInfo(this.SERVERBASE_URL, {
                name: this.userInfo.name,
                type: "提交评价",
                event: "扫查影像合格率",
                content: JSON.stringify({res:JSON.stringify(res),sNo:this.curDocRecord.sNo}),
              });
              if (this.userInfo.level == 7 && !this.blindReview) {
                this.hasQua = true;
              }
            } else {
              this.$message.error("评价失败!");
            }
          } else {
            this.$message.warning("评价失败!");
          }
        }
      } else if (type == "recognition") {
        const res = this.$refs.Recognition.getResult();
        if (this.forms.length > 0) {
          const target = this.forms.find((item) => item.evaluationID == 1);
          console.log("target", target, "评价结果", res);
          if (res && Object.keys(target).length > 0) {
            const parmas = {
              id: target.id,
              evaluationResult: JSON.stringify(res),
            };
            const submit_res = await updateAssess(this.RECORD_URL, parmas);
            if (submit_res.code == 200) {
              this.recognition = false;
              this.$message.success("评价成功!");
              addLogInfo(this.SERVERBASE_URL, {
                name: this.userInfo.name,
                type: "提交评价",
                event: "标准切面识别率",
                content: JSON.stringify({res:JSON.stringify(res),sNo:this.curDocRecord.sNo}),
              });
              if (this.userInfo.level == 7 && !this.blindReview) {
                this.hasRec = true;
              }
            } else {
              this.$message.error("评价失败!");
            }
          } else {
            this.$message.error("评价失败!");
          }
        }
      } else if (type == "diagnosis") {
        const res = this.$refs.Diagnosis.getResult();
        if (this.forms.length > 0) {
          const target = this.forms.find((item) => item.evaluationID == 2);
          console.log("target", target, "评价结果", res);
          if (res && Object.keys(target).length > 0) {
            const parmas = {
              id: target.id,
              evaluationResult: JSON.stringify(res),
            };
            const submit_res = await updateAssess(this.RECORD_URL, parmas);
            if (submit_res.code == 200) {
              this.diagnosis = false;
              this.$message.success("评价成功!");
              addLogInfo(this.SERVERBASE_URL, {
                name: this.userInfo.name,
                type: "提交评价",
                event: "诊断一致性",
                content: JSON.stringify({res:JSON.stringify(res),sNo:this.curDocRecord.sNo}),
              });
              if (this.userInfo.level == 7 && !this.blindReview) {
                this.hasDia = true;
              }
            } else {
              this.$message.error("评价失败!");
            }
          } else {
            this.$message.error("评价失败!");
          }
        }
      }
    },
  },
};
</script>

<style scoped lang="less">
@import "~@/assets/css/report.less";
</style>
